[Cmake-commits] CMake branch, master, updated. 9676c52c3ea26dcd74bdffd14fa91869c00354f7

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Mar 18 13:53:54 EDT 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  9676c52c3ea26dcd74bdffd14fa91869c00354f7 (commit)
      from  a2fe175647718a562e41c84717b67917adbe584d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9676c52c3ea26dcd74bdffd14fa91869c00354f7
commit 9676c52c3ea26dcd74bdffd14fa91869c00354f7
Author: Zach Mullen <zach.mullen at kitware.com>
Date:   Thu Mar 18 13:51:40 2010 -0400

    Fix for StopTime for cases when gmtime is a day ahead of localtime

diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 8e7b9cd..adabbc2 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -531,10 +531,22 @@ double cmCTestRunTest::ResolveTimeout()
   time_t current_time = time(0);
   lctime = gmtime(&current_time);
   int gm_hour = lctime->tm_hour;
+  time_t gm_time = mktime(lctime);
   lctime = localtime(&current_time);
   int local_hour = lctime->tm_hour;
 
-  int timezone = (local_hour - gm_hour) * 100;
+  int tzone_offset = 0;
+  if(gm_time > current_time && gm_hour < local_hour)
+    {
+    // this means gm_time is on the next day
+    tzone_offset = local_hour - gm_hour - 24;
+    }
+  else
+    {
+    tzone_offset = local_hour - gm_hour;
+    }
+
+  tzone_offset *= 100;
   char buf[1024];
   // add todays year day and month to the time in str because
   // curl_getdate no longer assumes the day is today
@@ -543,10 +555,8 @@ double cmCTestRunTest::ResolveTimeout()
           lctime->tm_mon + 1,
           lctime->tm_mday,
           this->CTest->GetStopTime().c_str(),
-          timezone);
+          tzone_offset);
 
-  cmCTestLog(this->CTest, HANDLER_OUTPUT, "Computed stop time="
-    << buf << std::endl);
   time_t stop_time = curl_getdate(buf, &current_time);
   if(stop_time == -1)
     {
@@ -558,7 +568,7 @@ double cmCTestRunTest::ResolveTimeout()
     {
     stop_time += 24*60*60;
     }
-  double stop_timeout = stop_time - current_time;
+  int stop_timeout = (stop_time - current_time) % (24*60*60);
 
   if(stop_timeout <= 0)
     {
@@ -567,7 +577,8 @@ double cmCTestRunTest::ResolveTimeout()
     exit(-1);
     }
 #undef min
-  return timeout == 0 ? stop_timeout : std::min(timeout, stop_timeout);
+  return timeout == 0 ? stop_timeout :
+    std::min(timeout, static_cast<double>(stop_timeout));
 }
 
 //----------------------------------------------------------------------
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index c6a3849..098bd7a 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2557,10 +2557,22 @@ void cmCTest::DetermineNextDayStop()
   time_t current_time = time(0);
   lctime = gmtime(&current_time);
   int gm_hour = lctime->tm_hour;
+  time_t gm_time = mktime(lctime);
   lctime = localtime(&current_time);
   int local_hour = lctime->tm_hour;
 
-  int timezone = (local_hour - gm_hour) * 100;
+  int tzone_offset = 0;
+  if(gm_time > current_time && gm_hour < local_hour)
+    {
+    // this means gm_time is on the next day
+    tzone_offset = local_hour - gm_hour - 24;
+    }
+  else
+    {
+    tzone_offset = local_hour - gm_hour;
+    }
+
+  tzone_offset *= 100;
   char buf[1024];
   sprintf(buf, "%d%02d%02d %s %+05i",
           lctime->tm_year + 1900,
diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in
index 0d664ad..6a5534e 100644
--- a/Tests/CTestTestStopTime/test.cmake.in
+++ b/Tests/CTestTestStopTime/test.cmake.in
@@ -25,8 +25,8 @@ CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
 CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
 
 GET_DATE()
-message("original time: ${${GD_PREFIX}HOUR}:${${GD_PREFIX}MINUTE}:${${GD_PREFIX}SECOND}")
-ADD_SECONDS(25)
+message("curr time: ${${GD_PREFIX}HOUR}:${${GD_PREFIX}MINUTE}:${${GD_PREFIX}SECOND}")
+ADD_SECONDS(15)
 message("stop time: ${new_hr}:${new_min}:${new_sec}")
 
 CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res STOP_TIME "${new_hr}:${new_min}:${new_sec}")

-----------------------------------------------------------------------

Summary of changes:
 Source/CTest/cmCTestRunTest.cxx       |   23 +++++++++++++++++------
 Source/cmCTest.cxx                    |   14 +++++++++++++-
 Tests/CTestTestStopTime/test.cmake.in |    4 ++--
 3 files changed, 32 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list