git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-cvsimport: allow author-specific timezones

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 16, 2012, 03:50 UTC
Message-ID
<7v4nlvulc2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAEUsAPY3fJJSzX8WPRVQPNOF0A0KAMCXr1u0ZzjEFvXDF=v6JA@mail.gmail.com>
Chris Rorvick <chris@rorvick.com> writes:
Show 6 quoted lines
> It occurred to me that the success of the unit test depends on the
> host platform's zoneinfo database.  I think this problem is inherent
> with this functionality.  Should the unit test attempt to detect
> support for the used timezones and short circuit if this fails?  Not
> sure exactly how I'd do this, but wondering if it's worth thinking
> about.
Yeah, that did indeed cross my mind.

You could say TZ=QST6QDT or something silly like that but that in turn has to assume your tzset() is POSIX.1 compliant anyway.

We should at least protect the tests with prerequiste, perhaps like this.

 t/t9604-cvsimport-timestamps.sh | 53 ++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 30 deletions(-)
diff --git i/t/t9604-cvsimport-timestamps.sh w/t/t9604-cvsimport-timestamps.sh
index 6af41b7..f7683da 100755
--- i/t/t9604-cvsimport-timestamps.sh
+++ w/t/t9604-cvsimport-timestamps.sh
@@ -3,9 +3,30 @@
 test_description='git cvsimport timestamps'
 . ./lib-cvs.sh
 
+# Can your Perl grok these TZ settings correctly?
+test_lazy_prereq TZNAME '
+	perl -e '\''
+		use POSIX qw(strftime);
+		while (<STDIN>) {
+			my ($zone, $time, $expect) = split(q/ /);
+			$ENV{TZ} = $zone;
+			if (strftime(q/%z/, localtime($time)) ne $expect) {
+				exit(1);
+			}
+		}
+		exit(0);
+	'\'' <<-\EOF
+	America/Chicago 1345174000 -0500
+	America/Chicago 1329622000 -0600
+	Australia/Sydney 1345174000 +1000
+	Australia/Sydney 1329622000 +1100
+	Asia/Shanghai 1329622000 +0800
+	EOF
+'
+
 setup_cvs_test_repository t9604
 
-test_expect_success 'check timestamps are UTC (TZ=America/Chicago)' '
+test_expect_success TZNAME 'check timestamps are UTC (TZ=America/Chicago)' '
 	TZ=America/Chicago git cvsimport -p"-x" -C module-1 module &&
 	git cvsimport -p"-x" -C module-1 module &&
 	(
Previous: Chris RorvickNext: Jeff King
Message 4 of 6 in “git-cvsimport: allow author-specific timezones”
  1. git-cvsimport: allow author-specific timezonesChris Rorvick, Oct 15, 2012
  2. Junio C HamanoOct 15, 2012
  3. Chris RorvickOct 16, 2012
  4. Junio C HamanoOct 16, 2012
  5. Jeff KingOct 16, 2012
  6. Junio C HamanoOct 16, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.