threads / patch / 23548

patcht1304,t2007: quell output to stdout and stderr

Subject: [PATCH] t1304,t2007: quell output to stdout and stderr

## tl;dr

6 messages between Apr 21, 2010 and May 26, 2010. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Michael J Gruber· Apr 21, 2010, 13:55 UTC · lore

These tests send output to stdout or stderr even without -v. This is distracting because unexpected output flashing by during make test usually indicates problems

Shut them up uncoditionally: In both cases, the output was due to intermediate commands in between the actual test cases.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/t1304-default-acl.sh      |    2 +-
 t/t2007-checkout-symlink.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Show changes to 2 files +2 −2

t/t1304-default-acl.sh, t/t2007-checkout-symlink.sh

diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh
index 055ad00..b26d2e8 100755
--- a/t/t1304-default-acl.sh
+++ b/t/t1304-default-acl.sh
@@ -15,7 +15,7 @@ umask 077
 # is a good candidate: exists on all unices, and it has permission
 # anyway, so we don't create a security hole running the testsuite.
 
-if ! setfacl -m u:root:rwx .; then
+if ! setfacl -m u:root:rwx . 2>/dev/null; then
     say "Skipping ACL tests: unable to use setfacl"
     test_done
 fi
diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh
index 20f3343..fc5db05 100755
--- a/t/t2007-checkout-symlink.sh
+++ b/t/t2007-checkout-symlink.sh
@@ -45,7 +45,7 @@ test_expect_success 'switch from symlink to dir' '
 '
 
 rm -fr frotz xyzzy nitfol &&
-git checkout -f master || exit
+git checkout -q -f master || exit
 
 test_expect_success 'switch from dir to symlink' '
 
-- 
1.7.1.rc1.248.gcefbb
Jonathan Nieder· Apr 21, 2010, 14:45 UTC · re: Michael J Gruber · lore

Re: [PATCH] t1304,t2007: quell output to stdout and stderr

Hi Michael,
Michael J Gruber wrote:
Show 11 quoted lines
> --- a/t/t1304-default-acl.sh
> +++ b/t/t1304-default-acl.sh
> @@ -15,7 +15,7 @@ umask 077
>  # is a good candidate: exists on all unices, and it has permission
>  # anyway, so we don't create a security hole running the testsuite.
>  
> -if ! setfacl -m u:root:rwx .; then
> +if ! setfacl -m u:root:rwx . 2>/dev/null; then
>      say "Skipping ACL tests: unable to use setfacl"
>      test_done
>  fi
[and a similar suppression of ‘git checkout’ output]

In the spirit of commit 4a45f7d (Use test_expect_success for test setups, 2010-03-20), might it make sense to turn these into tests?

I am imagining something like this.
Show changes to 2 files +13 −4

t/t1304-default-acl.sh, t/t2007-checkout-symlink.sh

diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh
index b26d2e8..8b3ff7a 100755
--- a/t/t1304-default-acl.sh
+++ b/t/t1304-default-acl.sh
@@ -15,7 +15,15 @@ umask 077
 # is a good candidate: exists on all unices, and it has permission
 # anyway, so we don't create a security hole running the testsuite.
 
-if ! setfacl -m u:root:rwx . 2>/dev/null; then
+test_expect_success 'Setup: try to set an ACL' '
+	if setfacl -m u:root:rwx .
+	then
+		test_set_prereq ACL
+	fi
+'
+
+if ! test_have_prereq ACL
+then
     say "Skipping ACL tests: unable to use setfacl"
     test_done
 fi
diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh
index fc5db05..f8f40e5 100755
--- a/t/t2007-checkout-symlink.sh
+++ b/t/t2007-checkout-symlink.sh
@@ -44,11 +44,12 @@ test_expect_success 'switch from symlink to dir' '
 
 '
 
-rm -fr frotz xyzzy nitfol &&
-git checkout -q -f master || exit
-
 test_expect_success 'switch from dir to symlink' '
 
+	rm -fr frotz xyzzy nitfol &&
+	git rm -fr . &&
+	git checkout -f master &&
+
 	git checkout side
 
 '
Michael J Gruber· Apr 21, 2010, 14:53 UTC · re: Jonathan Nieder · lore

Re: [PATCH] t1304,t2007: quell output to stdout and stderr

Jonathan Nieder venit, vidit, dixit 21.04.2010 16:45:
Show 19 quoted lines
> Hi Michael,
> 
> Michael J Gruber wrote:
> 
>> --- a/t/t1304-default-acl.sh
>> +++ b/t/t1304-default-acl.sh
>> @@ -15,7 +15,7 @@ umask 077
>>  # is a good candidate: exists on all unices, and it has permission
>>  # anyway, so we don't create a security hole running the testsuite.
>>  
>> -if ! setfacl -m u:root:rwx .; then
>> +if ! setfacl -m u:root:rwx . 2>/dev/null; then
>>      say "Skipping ACL tests: unable to use setfacl"
>>      test_done
>>  fi
> [and a similar suppression of ‘git checkout’ output]
> 
> In the spirit of commit 4a45f7d (Use test_expect_success for test
> setups, 2010-03-20), might it make sense to turn these into tests?

In principle yes, of course, I've done this in other cases. But note that here, on both occasions, the test script wants to exit if prerequisites are not met. I don't think it's OK to exit or test_done from within test_expect_something, is it?

Show 43 quoted lines
> I am imagining something like this.
> 
> diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh
> index b26d2e8..8b3ff7a 100755
> --- a/t/t1304-default-acl.sh
> +++ b/t/t1304-default-acl.sh
> @@ -15,7 +15,15 @@ umask 077
>  # is a good candidate: exists on all unices, and it has permission
>  # anyway, so we don't create a security hole running the testsuite.
>  
> -if ! setfacl -m u:root:rwx . 2>/dev/null; then
> +test_expect_success 'Setup: try to set an ACL' '
> +	if setfacl -m u:root:rwx .
> +	then
> +		test_set_prereq ACL
> +	fi
> +'
> +
> +if ! test_have_prereq ACL
> +then
>      say "Skipping ACL tests: unable to use setfacl"
>      test_done
>  fi
> diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh
> index fc5db05..f8f40e5 100755
> --- a/t/t2007-checkout-symlink.sh
> +++ b/t/t2007-checkout-symlink.sh
> @@ -44,11 +44,12 @@ test_expect_success 'switch from symlink to dir' '
>  
>  '
>  
> -rm -fr frotz xyzzy nitfol &&
> -git checkout -q -f master || exit
> -
>  test_expect_success 'switch from dir to symlink' '
>  
> +	rm -fr frotz xyzzy nitfol &&
> +	git rm -fr . &&
> +	git checkout -f master &&
> +
>  	git checkout side
>  
>  '
Jonathan Nieder· Apr 21, 2010, 15:12 UTC · re: Michael J Gruber · lore

Re: [PATCH] t1304,t2007: quell output to stdout and stderr

Michael J Gruber wrote:
> I don't think it's OK to exit or test_done
> from within test_expect_something, is it?

exit: the consequences are the same whether you’re in a test or not. Either way, it’s bad. I think the intent of that ‘exit’ was to make a good effort to set up for the next test and skip the test if that didn’t work, which is a bit old-fashioned. Emptying the index before the checkout would make it like that the setup should not fail even if some related bug resurfaces.

test_done: not sure what would happen. Indeed, it doesn’t sound like a very sane thing to do. :)

Jonathan
Michael J Gruber· Apr 22, 2010, 20:45 UTC · re: Jonathan Nieder · lore

[PATCH v2] t1304,t2007: quell output to stdout and stderr

These tests send output to stdout or stderr even without -v. This is distracting because unexpected output flashing by during make test usually indicates problems.

Shut them up unconditionally by integrating them in test code: In both cases, the output was due to intermediate commands in between the actual test cases.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/t1304-default-acl.sh      |   10 +++++++++-
 t/t2007-checkout-symlink.sh |    5 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)
Show changes to 2 files +11 −4

t/t1304-default-acl.sh, t/t2007-checkout-symlink.sh

diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh
index 055ad00..8b3ff7a 100755
--- a/t/t1304-default-acl.sh
+++ b/t/t1304-default-acl.sh
@@ -15,7 +15,15 @@ umask 077
 # is a good candidate: exists on all unices, and it has permission
 # anyway, so we don't create a security hole running the testsuite.
 
-if ! setfacl -m u:root:rwx .; then
+test_expect_success 'Setup: try to set an ACL' '
+	if setfacl -m u:root:rwx .
+	then
+		test_set_prereq ACL
+	fi
+'
+
+if ! test_have_prereq ACL
+then
     say "Skipping ACL tests: unable to use setfacl"
     test_done
 fi
diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh
index 20f3343..e98ec4c 100755
--- a/t/t2007-checkout-symlink.sh
+++ b/t/t2007-checkout-symlink.sh
@@ -44,11 +44,10 @@ test_expect_success 'switch from symlink to dir' '
 
 '
 
-rm -fr frotz xyzzy nitfol &&
-git checkout -f master || exit
-
 test_expect_success 'switch from dir to symlink' '
 
+	rm -fr frotz xyzzy nitfol &&
+	git checkout -f master &&
 	git checkout side
 
 '
-- 
1.7.1.rc1.248.gcefbb
Michael J Gruber· May 26, 2010, 09:08 UTC · re: Michael J Gruber · lore

Re: [PATCH v2] t1304,t2007: quell output to stdout and stderr

Michael J Gruber venit, vidit, dixit 22.04.2010 22:45:
Show 11 quoted lines
> These tests send output to stdout or stderr even without -v. This is
> distracting because unexpected output flashing by during make test
> usually indicates problems.
> 
> Shut them up unconditionally by integrating them in test code: In both
> cases, the output was due to intermediate commands in between the actual
> test cases.
> 
> Helped-by: Jonathan Nieder <jrnieder@gmail.com>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
ping...

← back to recent threads