CVS update: /ccvs/lib/

[email protected] 15 Apr 2005 21:12:36 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
User: dprice  
Date: 05/04/15 14:12:36

Modified:
 /ccvs/lib/
  .cvsignore, ChangeLog, Makefile.am, Makefile.in, test-getdate.sh

Log:
 * Makefile.am (DISTCLEANFILES): Add getdate.log.
 * .cvsignore: Ditto.
 * test-getdate.sh: Add new tests.
 (verify, skip, valid_timezone): New functions.

File Changes:

Directory: /ccvs/lib/
=====================

File [changed]: .cvsignore
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/.cvsignore?r1=1.11&r2=1.12
Delta lines:  +1 -0
-------------------
--- .cvsignore	8 Mar 2005 23:25:43 -0000	1.11
+++ .cvsignore	15 Apr 2005 21:12:33 -0000	1.12
@@ -13,3 +13,4 @@
 stdbool.h
 stdint.h
 getdate
+getdate.log

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/ChangeLog?r1=1.412&r2=1.413
Delta lines:  +7 -0
-------------------
--- ChangeLog	12 Apr 2005 14:20:16 -0000	1.412
+++ ChangeLog	15 Apr 2005 21:12:33 -0000	1.413
@@ -1,3 +1,10 @@
+2005-04-15  Derek Price  <[email protected]>
+
+	* Makefile.am (DISTCLEANFILES): Add getdate.log.
+	* .cvsignore: Ditto.
+	* test-getdate.sh: Add new tests.
+	(verify, skip, valid_timezone): New functions.
+
 2005-04-12  Derek Price  <[email protected]>
 
 	* getdate.y: Update from GNULIB.

File [changed]: Makefile.am
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/Makefile.am?r1=1.94&r2=1.95
Delta lines:  +2 -0
-------------------
--- Makefile.am	23 Mar 2005 20:33:42 -0000	1.94
+++ Makefile.am	15 Apr 2005 21:12:33 -0000	1.95
@@ -38,6 +38,7 @@
 ## Zero some variables so Automake will allow us to use += on them.
 BUILT_SOURCES =
 MOSTLYCLEANFILES =
+DISTCLEANFILES =
 MAINTAINERCLEANFILES =
 TESTS =
 check_PROGRAMS =
@@ -120,6 +121,7 @@
 ## CVS test scripts for getdate.
 TESTS += test-getdate.sh
 MOSTLYCLEANFILES += getdate-expected getdate-got getdate.diff
+DISTCLEANFILES += getdate.log
 # Program required by test-getdate.sh for testing getdate.y.
 check_PROGRAMS += getdate
 getdate_SOURCES = \

File [changed]: Makefile.in
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/Makefile.in?r1=1.175&r2=1.176
Delta lines:  +2 -0
-------------------
--- Makefile.in	5 Apr 2005 20:43:29 -0000	1.175
+++ Makefile.in	15 Apr 2005 21:12:33 -0000	1.176
@@ -319,6 +319,7 @@
 MOSTLYCLEANFILES = alloca.h alloca.h-t fnmatch.h fnmatch.h-t \
 	getdate-expected getdate-got getdate.diff getopt.h getopt.h-t \
 	stdbool.h stdbool.h-t stdint.h stdint.h-t
+DISTCLEANFILES = getdate.log
 MAINTAINERCLEANFILES = 
 TESTS = test-getdate.sh
 
@@ -707,6 +708,7 @@
 
 distclean-generic:
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"

File [changed]: test-getdate.sh
Url: https://ccvs.cvshome.org/source/browse/ccvs/lib/test-getdate.sh?r1=1.6&r2=1.7
Delta lines:  +224 -11
----------------------
--- test-getdate.sh	11 Nov 2004 00:42:42 -0000	1.6
+++ test-getdate.sh	15 Apr 2005 21:12:33 -0000	1.7
@@ -18,6 +18,113 @@
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
+
+
+###
+### Globals
+###
+LOGFILE=`pwd`/getdate.log
+if test -f "$LOGFILE"; then
+	mv $LOGFILE $LOGFILE~
+fi
+
+
+
+###
+### Functions
+###
+verify ()
+{
+	echo >>getdate-got
+	if cmp getdate-expected getdate-got >getdate.cmp; then
+		echo "PASS: $1" >>$LOGFILE
+	else
+		cat getdate.cmp >>$LOGFILE
+		echo "** expected: " >>$LOGFILE
+		cat getdate-expected >>$LOGFILE
+		echo "** got: " >>$LOGFILE
+		cat getdate-got >>$LOGFILE
+		echo "FAIL: $1" | tee -a $LOGFILE >&2
+		echo "Failed!  See $LOGFILE for more!" >&2
+		exit 1
+	fi
+}
+
+
+
+skip ()
+{
+	echo "SKIP: $1"${2+" ($2)"} >>$LOGFILE
+}
+
+
+
+# Prep for future calls to valid_timezone().
+#
+# This should set $UTZ to three spaces, `GMT', `Unrecognized/Unrecognized', or
+# possibly the empty string, depending on what system we are running on.  With
+# any luck, this will catch any other existing variations as well.  The way it
+# is used later does have the disadvantage of rejecting at least the
+# `Europe/London' timezone for half the year when $UTZ gets set to `GMT', like
+# happens on NetBSD, but, since I haven't come up with any better ideas and
+# since rejecting a timezone just causes a few tests to be skipped, this will
+# have to do for now.
+#
+# UTZ stands for Unrecognized Time Zone.
+UTZ=`TZ=Unrecognized/Unrecognized date +%Z`
+
+# The following function will return true if $1 is a valid timezone.  It will
+# return false and set $skipreason, otherwise.
+#
+# Clobbers $NTZ & $skipreason.
+#
+# SUS2 says `date +%Z' will return `no characters' if `no timezone is
+# determinable'.  It is, unfortunately, not very specific about what
+# `determinable' means.  On GNU/Linux, `date +%Z' returns $TZ when $TZ is not
+# recognized.  NetBSD 1.6.1 "determines" that an unrecognizable value in $TZ
+# really means `GMT'.  On Cray, the standard is ignored and `date +%Z' returns
+# three spaces when $TZ is not recognized.  We test for all three cases, plus
+# the empty string for good measure, though I know of no set of conditions
+# which will actually cause `date +%Z' to return the empty string SUS2
+# specifies.
+#
+# Due to the current nature of this test, this will not work for the
+# three-letter zone codes on some systems.  e.g.:
+#
+#	test `TZ=EST date +%Z` = "EST"
+#
+# should, quite correctly, evaluate to true on most systems, but:
+#
+#	TZ=Asia/Calcutta date +%Z
+#
+# would return `IST' on GNU/Linux, and hopefully any system which understands
+# the `Asia/Calcutta' timezone, and `   ' on Cray.  Similarly:
+#
+#	TZ=Doesnt_Exist/Doesnt_Exist date +%Z
+#
+# returns `Doesnt_Exist/Doesnt_Exist' on GNU/Linux and `   ' on Cray.
+#
+# Unfortunately, the %z date format string (-HHMM format time zone) supported
+# by the GNU `date' command is not part of any standard I know of and,
+# therefore, is probably not portable.
+#
+valid_timezone ()
+{
+	NTZ=`TZ=$1 date +%Z`
+	if test "$NTZ" = "$UTZ" || test "$NTZ" = "$1"; then
+		skipreason="$1 is not a recognized timezone on this system"
+		return `false`
+	else
+		return `:`
+	fi
+}
+
+
+
+###
+### Tests
+###
+
 # Why are these dates tested?
 #
 # February 29, 2003
@@ -54,6 +161,10 @@
 #
 # 1996-12-12 1 month
 #   Test a relative date.
+
+
+
+# The following tests are currently being skipped for being unportable:
 #
 # Tue Jan 19 03:14:07 2038 +0000
 #   For machines with 31-bit time_t, any date past this date will be an
@@ -109,19 +220,121 @@
 1996-12-12 1 month
 EOF
 
-echo >>getdate-got
+verify getdate-1
 
-if cmp getdate-expected getdate-got >getdate.cmp; then :; else
-	LOGFILE=`pwd`/getdate.log
-	cat getdate.cmp >${LOGFILE}
-	echo "** expected: " >>${LOGFILE}
-	cat getdate-expected >>${LOGFILE}
-	echo "** got: " >>${LOGFILE}
-	cat getdate-got >>${LOGFILE}
-	echo "FAIL: getdate" | tee -a ${LOGFILE}
-	echo "Failed!  See ${LOGFILE} for more!" >&2
-	exit 1
+
+
+# Why are these dates tested?
+#
+# Ian Abbot reported these odd boundry cases.  After daylight savings time went
+# into effect, non-daylight time zones would cause
+# "Bad format - couldn't convert." errors, even when the non-daylight zone
+# happened to be a universal one, like GMT.
+
+TZ=Europe/London; export TZ
+if valid_timezone $TZ; then
+	cat >getdate-expected <<EOF
+Enter date, or blank line to exit.
+	> 2005-03-01 00:00:00.000000000
+	> 2005-03-27 00:00:00.000000000
+	> 2005-03-28 01:00:00.000000000
+	> 2005-03-28 01:00:00.000000000
+	> 2005-03-29 01:00:00.000000000
+	> 2005-03-29 01:00:00.000000000
+	> 2005-03-30 01:00:00.000000000
+	> 2005-03-30 01:00:00.000000000
+	> 2005-03-31 01:00:00.000000000
+	> 2005-03-31 01:00:00.000000000
+	> 2005-04-01 01:00:00.000000000
+	> 2005-04-01 01:00:00.000000000
+	> 2005-04-10 01:00:00.000000000
+	> 2005-04-10 01:00:00.000000000
+	> 2005-04-01 00:00:00.000000000
+	> 
+EOF
+
+	./getdate >getdate-got <<EOF
+2005-3-1 GMT
+2005-3-27 GMT
+2005-3-28 GMT
+2005-3-28 UTC0
+2005-3-29 GMT
+2005-3-29 UTC0
+2005-3-30 GMT
+2005-3-30 UTC0
+2005-3-31 GMT
+2005-3-31 UTC0
+2005-4-1 GMT
+2005-4-1 UTC0
+2005-4-10 GMT
+2005-4-10 UTC0
+2005-4-1 BST
+EOF
+
+	verify getdate-2
+else
+	skip getdate-2 "$skipreason"
+fi
+
+
+
+# Many of the following cases were also submitted by Ian Abbott, but the same
+# errors are not exhibited.  The original problem had a similar root, but
+# managed to produce errors with GMT, which is considered a "Universal Zone".
+# This was fixed.
+#
+# The deeper problem has to do with "local zone" processing in getdate.y
+# that causes local daylight zones to be excluded when local standard time is
+# in effect and vice versa.  This used to cause trouble with GMT in Britian
+# when British Summer Time was in effect, but this was overridden for the
+# "Universal Timezones" (GMT, UTC, & UT), that might double as a local zone in
+# some locales.  We still see in these tests the local daylight/standard zone
+# exclusion in EST/EDT.  According to Paul Eggert in a message to
+# [email protected] on 2005-04-12, this is considered a bug but may not be
+# fixed soon due to its complexity.
+
+TZ=America/New_York; export TZ
+if valid_timezone $TZ; then
+	cat >getdate-expected <<EOF
+Enter date, or blank line to exit.
+	> 2005-03-01 00:00:00.000000000
+	> 2005-02-28 18:00:00.000000000
+	> 2005-04-01 00:00:00.000000000
+	> Bad format - couldn't convert.
+	> 2005-04-30 19:00:00.000000000
+	> 2005-04-30 20:00:00.000000000
+	> 2005-05-01 00:00:00.000000000
+	> 2005-04-30 20:00:00.000000000
+	> Bad format - couldn't convert.
+	> 2005-05-31 19:00:00.000000000
+	> 2005-05-31 20:00:00.000000000
+	> 2005-06-01 00:00:00.000000000
+	> 2005-05-31 20:00:00.000000000
+	> 
+EOF
+
+	./getdate >getdate-got <<EOF
+2005-3-1 EST
+2005-3-1 BST
+2005-4-1 EST
+2005-5-1 EST
+2005-5-1 BST
+2005-5-1 GMT
+2005-5-1 EDT
+2005-5-1 UTC0
+2005-6-1 EST
+2005-6-1 BST
+2005-6-1 GMT
+2005-6-1 EDT
+2005-6-1 UTC0
+EOF
+
+	verify getdate-3
+else
+	skip getdate-3 "$skipreason"
 fi
 
+
+
 rm getdate-expected getdate-got getdate.cmp
 exit 0