Dixi quod…

>Now, I’m suspecting a timing issue or something, so if anyone

… but while writing that, I saw this:

>       Argument [34] Oct 1999 [0-9][0-9]:00:00 -0000

>       Argument 3 Oct 1999 23:59:38 -0000

That made me curious, and indeed:

tg@blau:~ $ date; TZ=UTC0 date; TZ= date
Sat Oct 22 18:50:58 UTC 2016
Sat Oct 22 18:50:58 UTC 2016
Sat Oct 22 18:51:24 UTC 2016

So sanity.sh (which, IMHO, probably ought to have been called
insanity.sh instead ☺) fails to properly restore an unset $TZ.

Fix attached for your convenience.

PASS: test-getdate.sh
==================
All 1 tests passed
==================
Making check in diff
Making check in src
/usr/bin/make  check-local
/bin/mksh ./sanity.sh `pwd`/cvs
This test should produce no other output than this message, and a final "OK".
(Note that the test can take an hour or more to run and periodically stops
for as long as one minute.  Do not assume there is a problem just because
nothing seems to happen for a long time.  If you cannot live without
running status, try the command: `tail -f check.log' from another window.)
OK, all 3587 tests passed (11 test groups skipped).
/bin/mksh ./sanity.sh -r `pwd`/cvs
This test should produce no other output than this message, and a final "OK".
(Note that the test can take an hour or more to run and periodically stops
for as long as one minute.  Do not assume there is a problem just because
nothing seems to happen for a long time.  If you cannot live without
running status, try the command: `tail -f check.log' from another window.)
OK, all 3780 tests passed (1 test group skipped).
/bin/mksh ./sanity.sh -p `pwd`/cvs
This test should produce no other output than this message, and a final "OK".
(Note that the test can take an hour or more to run and periodically stops
for as long as one minute.  Do not assume there is a problem just because
nothing seems to happen for a long time.  If you cannot live without
running status, try the command: `tail -f check.log' from another window.)
OK, all 3614 tests passed (3 test groups skipped).

bye,
//mirabilos
-- 
“It is inappropriate to require that a time represented as
 seconds since the Epoch precisely represent the number of
 seconds between the referenced time and the Epoch.”
        -- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2
--- src/sanity.sh       Sat Oct 22 15:35:07 2016
+++ src/sanity.sh       Sat Oct 22 15:40:12 2016
@@ -1,5 +1,7 @@
 #! /bin/sh
 :
+# $MirOS: src/gnu/usr.bin/cvs/src/sanity.sh,v 1.4 2016/10/22 15:40:12 tg Exp $
+#-
 # set DISABLE_ANY_RSH=1 to skip rsh and ssh calls
 #
 #      sanity.sh -- a growing testsuite for cvs.
@@ -92,6 +94,23 @@ checklongoptarg()
     fi
 }
 
+do_save_TZ()
+{
+       saveset_TZ=${TZ+false}
+       save_TZ=$TZ
+       TZ=UTC0; export TZ
+}
+
+do_restore_TZ()
+{
+       if $saveset_TZ :; then
+               unset TZ
+       else
+               TZ=$save_TZ
+               export TZ
+       fi
+}
+
 # See TODO list at end of file.
 
 # required to make this script work properly.
@@ -9376,8 +9395,7 @@ add
          # Also the -d option.
 
          # Set a predictable time zone for these tests.
-         save_TZ=$TZ
-         TZ=UTC0; export TZ
+         do_save_TZ
 
          mkdir 1; cd 1
          mkdir adir bdir cdir
@@ -9500,7 +9518,7 @@ import-it
          dotest_fail importc-12 "test -d ${TESTDIR}/other" ""
 
          dokeep
-         TZ=$save_TZ
+         do_restore_TZ
          cd ..
          rm -r 1 2
          modify_repo rm -rf $CVSROOT_DIRNAME/first-dir
@@ -22119,8 +22137,7 @@ ${SPROG} update: Updating crerepos-dir"
 
          # Save the timezone and set it to UTC for these tests to make the
          # value more predicatable.
-         save_TZ=$TZ
-         TZ=UTC0; export TZ
+         do_save_TZ
 
          modify_repo mkdir $CVSROOT_DIRNAME/first-dir
 
@@ -22597,7 +22614,7 @@ revision 1\.5
 revision 1\.4"
 
          dokeep
-         TZ=$save_TZ
+         do_restore_TZ
          cd ..
          rm -r first-dir
          modify_repo rm -rf $CVSROOT_DIRNAME/first-dir
@@ -22787,8 +22804,7 @@ EOF
          # revisions 1.1 and 1.1.1.1 differ by 1 second.
 
          # Need a predictable time zone.
-         save_TZ=$TZ
-         TZ=UTC0; export TZ
+         do_save_TZ
 
           mkdir rcs4
           cd rcs4
@@ -22846,7 +22862,7 @@ File: file1             Status: Up-to-da
    Sticky Options:     (none)'
 
          dokeep
-         TZ=$save_TZ
+         do_restore_TZ
          cd ../..
           rm -r rcs4
           modify_repo rm -rf $CVSROOT_DIRNAME/rcs4-dir
@@ -25438,8 +25454,7 @@ done"
          #             for checkout and update as well.
          #
          mkdir 1; cd 1
-         save_TZ=$TZ
-         TZ=UTC0; export TZ
+         do_save_TZ
          dotest tagdate-1 "${testcvs} -q co -l ." ''
          mkdir first-dir
          dotest tagdate-2 "${testcvs} add first-dir" \
@@ -25903,7 +25918,7 @@ File: file3             Status: Up-to-da
 
          unset date_T1 date_T2 date_T3 date_T4 date_T5
          unset date_T6 date_T7 date_T8 date_T9
-         TZ=$save_TZ
+         do_restore_TZ
 
          dokeep
          rm -r 1 2 3 4

Reply via email to