Re: Regression in v2.26.0-rc0 and Magit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SZEDER Gábor <szeder.dev@xxxxxxxxx> writes:

>> +test_expect_success 'log and ls-files in a bare repository' '
>> +	(
>> +		cd bare &&
>> +		test_must_fail git log -- .. &&
>> +		test_must_fail git ls-files -- ..
>> +	) >out 2>err &&
>> +	test_i18ngrep "outside repository" err
>
> I think it would be better to write this test as:
>
>   (
>         cd bare &&
>         test_must_fail git log -- .. 2>err &&
> 	test_i18ngrep "outside repository" err &&
>         test_must_fail git ls-files -- .. 2>err &&
> 	test_i18ngrep "outside repository" err
>   )
>
> because this way we make sure that both commands fail with the error
> we expect.

True.  Otherwise one may fail expectedly, and the other one may fail
in an unexpected but still clean way.  Thanks for carefully reading.

We could also split it into two separate tests, but I think it would
be an overkill.  The primary point of using must-fail is to ensure
that the command does not segfault, so in a sense, checking what is
in err is somewhat, but not completely, a redundant thing to do.

About checking redundantly, as we grab the standard output, we can
also make sure that it contains nothing, because we expect that the
failure happens way before the command is set up to compute what
they are asked to produce.

Below, I follow your suggestion to keep the log/ls-files pair in a
single test, as I think splitting it into two is an overkill, but I
kept the "truly bare repository" case and the "non-bare repository,
but we stepped into $GIT_DIR ourselves" case separate, and that is
deliberate.  We might want to rethink the behaviour in the latter
case.

diff --git a/t/t6136-pathspec-in-bare.sh b/t/t6136-pathspec-in-bare.sh
new file mode 100755
index 0000000000..b117251366
--- /dev/null
+++ b/t/t6136-pathspec-in-bare.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='diagnosing out-of-scope pathspec'
+
+. ./test-lib.sh
+
+test_expect_success 'setup a bare and non-bare repository' '
+	test_commit file1 &&
+	git clone --bare . bare
+'
+
+test_expect_success 'log and ls-files in a bare repository' '
+	(
+		cd bare &&
+		test_must_fail git log -- .. >out 2>err &&
+		test_must_be_empty out &&
+		test_i18ngrep "outside repository" err &&
+
+		test_must_fail git ls-files -- .. >out 2>err &&
+		test_must_be_empty out &&
+		test_i18ngrep "outside repository" err
+	)
+'
+
+test_expect_success 'log and ls-files in .git directory' '
+	(
+		cd .git &&
+		test_must_fail git log -- .. >out 2>err &&
+		test_must_be_empty out &&
+		test_i18ngrep "outside repository" err &&
+
+		test_must_fail git ls-files -- .. >out 2>err &&
+		test_must_be_empty out &&
+		test_i18ngrep "outside repository" err
+	)
+'
+
+test_done




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux