From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Junio C Hamano <junkio@cox.net>
Cc: arjen@yaph.org (Arjen Laarhoven), Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] t5300-pack-object.sh: portability issue using /usr/bin/stat
Date: Fri, 06 Apr 2007 19:45:06 -0700 [thread overview]
Message-ID: <86odm0sy19.fsf@blue.stonehenge.com> (raw)
In-Reply-To: <7vfy7dgcn1.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Fri, 06 Apr 2007 19:08:02 -0700")
>>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:
Junio> arjen@yaph.org (Arjen Laarhoven) writes:
>> In the test 'compare delta flavors', /usr/bin/stat is used to get file size.
>> This isn't portable. There already is a dependency on Perl, use its '-s'
>> operator to get the file size.
Junio> If you do use Perl, then you do not want to do it as two
Junio> separate invocations with their result compared with test.
Junio> How about this on top of your patch?
Junio> diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
Junio> index a400e7a..5710a23 100755
Junio> --- a/t/t5300-pack-object.sh
Junio> +++ b/t/t5300-pack-object.sh
Junio> @@ -123,11 +123,13 @@ test_expect_success \
Junio> done'
Junio> cd "$TRASH"
Junio> -test_expect_success \
Junio> - 'compare delta flavors' \
Junio> - 'size_2=`perl -e "print -s q[test-2-${packname_2}.pack]"` &&
Junio> - size_3=`perl -e "print -s q[test-3-${packname_3}.pack]"` &&
Junio> - test $size_2 -gt $size_3'
Junio> +test_expect_success 'compare delta flavors' '
Junio> + perl -e "
Junio> + exit ( ((-s q[test-2-${packname_2}.pack]) >
Junio> + (-s q[test-3-${packname_3}.pack]))
Junio> + ? 0 : 1);
Junio> + "
Junio> +'
I'd go with:
perl -e '
defined($_ = -s $_) or die for @ARGV;
exit 1 if $ARGV[0] <= $ARGV[1];
' test-2-$packname_2.pack test-3.$packname_3.pack
which also tests to make sure the -s returned something, and works a lot less
hard to quote the filenames coming in (they come in via @ARGV instead of
triple interpolation). I'm not sure how to shoehorn that into
test_expect_success, but this is better Perl at least. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
prev parent reply other threads:[~2007-04-07 2:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-06 23:49 [PATCH] t5300-pack-object.sh: portability issue using /usr/bin/stat Arjen Laarhoven
2007-04-07 2:08 ` Junio C Hamano
2007-04-07 2:33 ` Nicolas Pitre
2007-04-07 4:13 ` Junio C Hamano
2007-04-07 12:39 ` Nicolas Pitre
2007-04-07 2:45 ` Randal L. Schwartz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86odm0sy19.fsf@blue.stonehenge.com \
--to=merlyn@stonehenge.com \
--cc=arjen@yaph.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.