# [PATCH] Skip unwritable tests for root

5 messages from 2008-06-30 to 2008-07-07. Participants: Fernando J. Pereda, Jakub Narebski, Junio C Hamano, Lea Wiemann.
Thread: https://gitlist.dev/t/14218

## Fernando J. Pereda, 2008-06-30 07:05

Subject: [PATCH] Skip unwritable tests for root
Message-ID: <1214809551-14603-1-git-send-email-ferdy@ferdyx.org>
URL: https://gitlist.dev/e/1214809551-14603-1-git-send-email-ferdy%40ferdyx.org

```
Signed-off-by: Fernando J. Pereda <ferdy@ferdyx.org>
---
 t/t0004-unwritable.sh |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

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, 2008-06-30 07:39

Subject: Re: [PATCH] Skip unwritable tests for root
Message-ID: <m3vdzrgymx.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3vdzrgymx.fsf%40localhost.localdomain
In-Reply-To: <1214809551-14603-1-git-send-email-ferdy@ferdyx.org>

```
"Fernando J. Pereda" <ferdy@ferdyx.org> writes:

> +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, 2008-06-30 09:08

Subject: Re: [PATCH] Skip unwritable tests for root
Message-ID: <7vabh31e9p.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vabh31e9p.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1214809551-14603-1-git-send-email-ferdy@ferdyx.org>

```
"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, 2008-06-30 09:27

Subject: Re: [PATCH] Skip unwritable tests for root
Message-ID: <20080630092735.GA10979@ferdyx.org>
URL: https://gitlist.dev/e/20080630092735.GA10979%40ferdyx.org
In-Reply-To: <7vabh31e9p.fsf@gitster.siamese.dyndns.org>

```
On Mon, Jun 30, 2008 at 02:08:18AM -0700, Junio C Hamano wrote:
> "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, 2008-07-07 19:14

Subject: Re: [PATCH] Skip unwritable tests for root
Message-ID: <48726AFE.3070400@gmail.com>
URL: https://gitlist.dev/e/48726AFE.3070400%40gmail.com
In-Reply-To: <7vabh31e9p.fsf@gitster.siamese.dyndns.org>

```
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:
> "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...)

```
