threads / patch / 920

patchUnset TZ in t5000

Subject: [PATCH] Unset TZ in t5000

## tl;dr

6 messages between Jun 13, 2005 and Jun 14, 2005. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Mark Allen· Jun 13, 2005, 00:24 UTC · lore
Unset TZ in t5000 and remove GNU awkism

The t5000 test script fails at test #4 on my box because my copy of tar adjusts the time in the tarfile for local time if TZ is set. Explicitly unset TZ so that it reports GMT time. Additionally, my version of AWK doesn't like the "length" directive, so this patch removes it.

Signed-off-by: Mark Allen <mrallen1@yahoo.com>
Show changes to t/t5000-tar-tree.sh +2 −2
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -50,8 +50,8 @@ test_expect_success \
 
 test_expect_success \
     'validate file modification time' \
-    'tar tvf b.tar a/a |
-     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
+    'TZ= tar tvf b.tar a/a |
+     awk \{print\ \$4\"\ \"\$5\} >b.mtime &&
      echo "2005-05-27 22:00:00" >expected.mtime &&
      diff expected.mtime b.mtime'
Rene Scharfe· Jun 13, 2005, 15:54 UTC · re: Mark Allen · lore

Re: [PATCH] Unset TZ in t5000

Mark Allen schrieb:
Show 5 quoted lines
> Unset TZ in t5000 and remove GNU awkism
> 
> The t5000 test script fails at test #4 on my box because my copy of 
> tar adjusts the time in the tarfile for local time if TZ is set. 
> Explicitly unset TZ so that it reports GMT time.
Good idea.
> Additionally, my version of AWK doesn't like the "length" directive, 
> so this patch removes it.

What kind of AWK is that? The One True AWK certainly has a length function for strings and POSIX mandates it, too, so it's not a GNUism.

The expression
   length($5)<7 ? $5":00" : $5

(where $5 is a time value) is there to cope with tars that format the time like hh:mm instead of the expected hh:mm:ss. If you have to remove the call to "length", please replace the thing with something equivalent, like

   match($5, /:.*:/) ? $5 : $5":00"
or similar, instead of simply dropping that test.

Thanks, Rene

Mark Allen· Jun 13, 2005, 17:27 UTC · re: Rene Scharfe · lore

Re: [PATCH] Unset TZ in t5000

--- Rene Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
Show 15 quoted lines
> What kind of AWK is that?  The One True AWK certainly has a length
> function for strings and POSIX mandates it, too, so it's not a GNUism.
> 
> The expression
> 
>    length($5)<7 ? $5":00" : $5
> 
> (where $5 is a time value) is there to cope with tars that format the
> time like hh:mm instead of the expected hh:mm:ss.  If you have to remove
> the call to "length", please replace the thing with something
> equivalent, like
> 
>    match($5, /:.*:/) ? $5 : $5":00"
> 
> or similar, instead of simply dropping that test.
Hi Rene,

I'll test your suggestion later tonight (US time) when I get home from work. Sorry I don't know much about awk. (I usually break out perl for any job I used to give awk) When I ran the t5000 script in --verbose mode, all I could see was awk complaining about the length directive.

It *is* possible that there's some kind of quoting/character escape problem which Linux tolerates but is causing the syntax error on my home system. (It's Mac OS 10.4.1/Darwin)

Thanks,
--Mark
Mark Allen· Jun 14, 2005, 13:17 UTC · re: Rene Scharfe · lore

Re: [PATCH] Unset TZ in t5000

--- Rene Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:> Mark Allen schrieb:
 > The expression
Show 5 quoted lines
> 
>    length($5)<7 ? $5":00" : $5
> 
> (where $5 is a time value) is there to cope with tars that format the
> time like hh:mm instead of the expected hh:mm:ss.

I put (escaped) parenthesis around the length function and now it works as expected. Here's a new patch. Please ack if you approve.

Thanks,
--Mark
Signed-off-by: Mark Allen <mrallen1@yahoo.com>
Show changes to t/t5000-tar-tree.sh +3 −2
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -50,8 +50,9 @@ test_expect_success \
 
 test_expect_success \
     'validate file modification time' \
-    'tar tvf b.tar a/a |
-     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
+    'TZ= tar tvf b.tar a/a |
+     awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
+     >b.mtime &&
      echo "2005-05-27 22:00:00" >expected.mtime &&
      diff expected.mtime b.mtime'
 
Rene Scharfe· Jun 14, 2005, 15:17 UTC · re: Mark Allen · lore

Re: [PATCH] Unset TZ in t5000

Mark Allen schrieb:
Show 36 quoted lines
> --- Rene Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:> Mark Allen schrieb:
>  > The expression
> 
>>   length($5)<7 ? $5":00" : $5
>>
>>(where $5 is a time value) is there to cope with tars that format the
>>time like hh:mm instead of the expected hh:mm:ss.
> 
> 
> I put (escaped) parenthesis around the length function and now it works as expected.
> Here's a new patch. Please ack if you approve. 
> 
> Thanks,
> 
> --Mark
> 
> Signed-off-by: Mark Allen <mrallen1@yahoo.com>
> 
> 
> ------------------------------------------------------------------------
> 
> diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
> --- a/t/t5000-tar-tree.sh
> +++ b/t/t5000-tar-tree.sh
> @@ -50,8 +50,9 @@ test_expect_success \
>  
>  test_expect_success \
>      'validate file modification time' \
> -    'tar tvf b.tar a/a |
> -     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
> +    'TZ= tar tvf b.tar a/a |
> +     awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
> +     >b.mtime &&
>       echo "2005-05-27 22:00:00" >expected.mtime &&
>       diff expected.mtime b.mtime'
>  
Acked-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Mark Allen· Jun 14, 2005, 17:09 UTC · re: Rene Scharfe · lore

Re: [PATCH] Unset TZ in t5000

Linus,
Please apply this patch to make t5000 more portable.
Thanks,
--Mark
---

Unset TZ to force GMT in test #4 and add a set of parens around the length function in the awk script.

Signed-off-by: Mark Allen <mrallen1@yahoo.com>
Acked-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
 
Show changes to t/t5000-tar-tree.sh +3 −2
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -50,8 +50,9 @@ test_expect_success \
 
 test_expect_success \
     'validate file modification time' \
-    'tar tvf b.tar a/a |
-     awk \{print\ \$4,\ length\(\$5\)\<7\ ?\ \$5\":00\"\ :\ \$5\} >b.mtime &&
+    'TZ= tar tvf b.tar a/a |
+     awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
+     >b.mtime &&
      echo "2005-05-27 22:00:00" >expected.mtime &&
      diff expected.mtime b.mtime'
 

← back to recent threads