threads / patch / 14218

patchSkip unwritable tests for root

Subject: [PATCH] Skip unwritable tests for root

## tl;dr

5 messages between Jun 30, 2008 and Jul 7, 2008. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Fernando J. Pereda· Jun 30, 2008, 07:05 UTC · lore
Signed-off-by: Fernando J. Pereda <ferdy@ferdyx.org>
---
 t/t0004-unwritable.sh |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
Show changes to t/t0004-unwritable.sh +7 −0
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
index 9255c63..728ec22 100755
--- a/t/t0004-unwritable.sh
+++ b/t/t0004-unwritable.sh
@@ -4,6 +4,13 @@ test_description='detect unwritable repository and fail correctly'
 
 . ./test-lib.sh
 
+if test "$(id -u)" -eq 0
+then
+	test_expect_success 'root writes to unwritable places, skipping test' :
+	test_done
+	exit
+fi
+
 test_expect_success setup '
 
 	>file &&
-- 
1.5.6.1
Jakub Narebski· Jun 30, 2008, 07:39 UTC · re: Fernando J. Pereda · lore

Re: [PATCH] Skip unwritable tests for root

"Fernando J. Pereda" <ferdy@ferdyx.org> writes:
Show 6 quoted lines
> +if test "$(id -u)" -eq 0
> +then
> +	test_expect_success 'root writes to unwritable places, skipping test' :
> +	test_done
> +	exit
> +fi

Yet another place that would profit from test_skip in test-lib.sh... (Junio uses "say skip" instead of "test_expect_success" in the place like above here).

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Junio C Hamano· Jun 30, 2008, 09:08 UTC · re: Fernando J. Pereda · lore

Re: [PATCH] Skip unwritable tests for root

"Fernando J. Pereda" <ferdy@ferdyx.org> writes:
> Signed-off-by: Fernando J. Pereda <ferdy@ferdyx.org>

Hmm. Actually we've deliberately ignored this so far. If we were to do anything, don't we rather want to fail everything upfront when the tests are run by root?

Running "make" and "make test" before "make install" is so that you have less chance hurting your running system, and I find it simply crazy to build (i.e. "make all") as root, let alone running tests.

Fernando J. Pereda· Jun 30, 2008, 09:27 UTC · re: Junio C Hamano · lore

Re: [PATCH] Skip unwritable tests for root

On Mon, Jun 30, 2008 at 02:08:18AM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> "Fernando J. Pereda" <ferdy@ferdyx.org> writes:
> 
> > Signed-off-by: Fernando J. Pereda <ferdy@ferdyx.org>
> 
> Hmm.  Actually we've deliberately ignored this so far.  If we were to do
> anything, don't we rather want to fail everything upfront when the tests
> are run by root?
> 
> Running "make" and "make test" before "make install" is so that you have
> less chance hurting your running system, and I find it simply crazy to
> build (i.e. "make all") as root, let alone running tests.
*nod*

This originated because Gentoo can be told to build stuff as root (and run test as root) under a sandbox. Since I already had the patch locally, I guessed you might be interested in it and just sent it.

I'll just apply it locally.
- ferdy
Lea Wiemann· Jul 7, 2008, 19:14 UTC · re: Junio C Hamano · lore

Re: [PATCH] Skip unwritable tests for root

Junio C Hamano wrote:
> If we were to do anything, don't we rather want to fail everything upfront
> when the tests are run by root [because it's crazy]?

I think that unless/until someone wants to submit a patch that makes the tests fail upfront, we should use Fernando's patch; it's an improvement over the current situation.

I'm actually not entirely sure if skipping or failing everything if the tests are run as root is a good idea -- for instance, neither skipping nor failing seems appropriate for Gentoo's root-in-a-sandbox situation.

Jakub Narebski wrote:
Show 6 quoted lines
> "Fernando J. Pereda" <ferdy@ferdyx.org> writes:
>> +	test_expect_success '[...], skipping test' :
>> +	test_done
>> +	exit
>
> Yet another place that would profit from test_skip in test-lib.sh...

*nods* I'd rather name it 'test_skip_all' for clarity though, at least if it contains "test_done; exit". (I'm not volunteering to send a patch, FTR...)

← back to recent threads