summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestScriptHandler.cxx
diff options
context:
space:
mode:
authorWouter Klouwen <wouter.klouwen@youview.com>2017-11-20 20:55:13 (GMT)
committerBrad King <brad.king@kitware.com>2017-12-04 15:43:14 (GMT)
commit66419bc04620c5748df77e2b563d65b0e97b623a (patch)
tree0c6e38ba923c4eb95c3d5d829c83a849d58eb52a /Source/CTest/cmCTestScriptHandler.cxx
parent923b8fadd5fe6af56197cf3916a3292b60c0e8db (diff)
downloadCMake-66419bc04620c5748df77e2b563d65b0e97b623a.zip
CMake-66419bc04620c5748df77e2b563d65b0e97b623a.tar.gz
CMake-66419bc04620c5748df77e2b563d65b0e97b623a.tar.bz2
CTest: convert timeouts to std::chrono::duration
This commit continues the refactoring of CTest to adopt std::chrono. After the last sets of changes that introduced std::chrono::steady_clock and std::chrono::system_clock respectively, it makes sense to have all the timeouts be stored as std::chrono::duration. No functional change intended.
Diffstat (limited to 'Source/CTest/cmCTestScriptHandler.cxx')
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index d2ad8c5..922f5c7 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -1,5 +1,12 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifdef _WIN32
+/* windows.h defines min() and max() macros, unless told to otherwise. This
+ * interferes with std::min() and std::max() at the very least. */
+#define NOMINMAX
+#endif
+
#include "cmCTestScriptHandler.h"
#include "cmsys/Directory.hxx"
@@ -960,21 +967,21 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
return cmSystemTools::RemoveADirectory(directoryPath);
}
-double cmCTestScriptHandler::GetRemainingTimeAllowed()
+std::chrono::duration<double> cmCTestScriptHandler::GetRemainingTimeAllowed()
{
if (!this->Makefile) {
- return 1.0e7;
+ return std::chrono::duration<double>::max();
}
const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
if (!timelimitS) {
- return 1.0e7;
+ return std::chrono::duration<double>::max();
}
auto timelimit = std::chrono::duration<double>(atof(timelimitS));
auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(
std::chrono::steady_clock::now() - this->ScriptStartTime);
- return (timelimit - duration).count();
+ return (timelimit - duration);
}