[v2,2/4] t3000: move non-submodule repo test to separate file
diff mbox series

Message ID 20190402183505.31512-3-kyle@kyleam.com
State New
Headers show
Series
  • dir: Treat a repository without commits as a repository
Related show

Commit Message

Kyle Meyer April 2, 2019, 6:35 p.m. UTC
a2d5156c2b (resolve_gitlink_ref: ignore non-repository paths,
2016-01-22) added a test to t3000-ls-files-others.sh to check that
'ls-files -o' does not die() when given a subdirectory that looks like
a repository but is actually a subdirectory containing a bogus .git
file.

Move this test to a separate file in preparation for testing scenarios
with non-submodule repositories that are not bogus.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
---
 t/t3000-ls-files-others.sh              |  7 -------
 t/t3009-ls-files-others-nonsubmodule.sh | 21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 7 deletions(-)
 create mode 100755 t/t3009-ls-files-others-nonsubmodule.sh

Comments

Junio C Hamano April 3, 2019, 7:59 a.m. UTC | #1
Kyle Meyer <kyle@kyleam.com> writes:

> a2d5156c2b (resolve_gitlink_ref: ignore non-repository paths,
> 2016-01-22) added a test to t3000-ls-files-others.sh to check that
> 'ls-files -o' does not die() when given a subdirectory that looks like
> a repository but is actually a subdirectory containing a bogus .git
> file.
>
> Move this test to a separate file in preparation for testing scenarios
> with non-submodule repositories that are not bogus.

It is unclear to me why this is needed.

> +++ b/t/t3009-ls-files-others-nonsubmodule.sh
> @@ -0,0 +1,21 @@
> +#!/bin/sh
> +
> +test_description='test git ls-files --others with non-submodule repositories'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'setup: expected output' '
> +	cat >expected <<-EOF
> +	expected
> +	output
> +	EOF
> +'

I think this is overkill.  Usually we have one expectation for a
single test, so having the above inside the actual test below makes
more sense.

Or are you planning to add more tests before the test_done we see
below, all of which expect the above output?  It would make perfect
sense if it were the case, but I do not think that is what is
happenning here...

> +test_expect_success 'ls-files --others handles non-submodule .git' '
> +	mkdir not-a-submodule &&
> +	echo foo >not-a-submodule/.git &&
> +	git ls-files -o >output &&
> +	test_cmp expected output
> +'
> +
> +test_done
Kyle Meyer April 3, 2019, 10:21 p.m. UTC | #2
Junio C Hamano <gitster@pobox.com> writes:

> Kyle Meyer <kyle@kyleam.com> writes:
>
>> a2d5156c2b (resolve_gitlink_ref: ignore non-repository paths,
>> 2016-01-22) added a test to t3000-ls-files-others.sh to check that
>> 'ls-files -o' does not die() when given a subdirectory that looks like
>> a repository but is actually a subdirectory containing a bogus .git
>> file.
>>
>> Move this test to a separate file in preparation for testing scenarios
>> with non-submodule repositories that are not bogus.
>
> It is unclear to me why this is needed.

It's not needed.  My thinking, which I didn't do a good job of spelling
out above, is

    We're going to be adding a test that checks how 'ls-files -o'
    handles a few different scenarios involving untracked repositories.
    This new test should go into a separate file rather than
    t3000-ls-files-others.sh because it substantially changes the shared
    directory layout that the t3000 tests work on.  Like the upcoming
    test, the "non-submodule .git" test from t3000 deals with a (bogus)
    untracked repository, so let's split it off into a separate test
    file that will be extended with the other scenarios.

Perhaps that's not a good reason to touch t3000, though.  I could drop
this patch, as well as the next one, and just add the new test file in
the final patch.

>> +++ b/t/t3009-ls-files-others-nonsubmodule.sh
>> @@ -0,0 +1,21 @@
>> +#!/bin/sh
>> +
>> +test_description='test git ls-files --others with non-submodule repositories'
>> +
>> +. ./test-lib.sh
>> +
>> +test_expect_success 'setup: expected output' '
>> +	cat >expected <<-EOF
>> +	expected
>> +	output
>> +	EOF
>> +'
>
> I think this is overkill.  Usually we have one expectation for a
> single test, so having the above inside the actual test below makes
> more sense.

OK, I'll move this into the test.

Patch
diff mbox series

diff --git a/t/t3000-ls-files-others.sh b/t/t3000-ls-files-others.sh
index afd4756134..b4f9fc4580 100755
--- a/t/t3000-ls-files-others.sh
+++ b/t/t3000-ls-files-others.sh
@@ -65,13 +65,6 @@  test_expect_success '--no-empty-directory hides empty directory' '
 	test_cmp expected3 output
 '
 
-test_expect_success 'ls-files --others handles non-submodule .git' '
-	mkdir not-a-submodule &&
-	echo foo >not-a-submodule/.git &&
-	git ls-files -o >output &&
-	test_cmp expected1 output
-'
-
 test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' '
 	git init super &&
 	git init sub &&
diff --git a/t/t3009-ls-files-others-nonsubmodule.sh b/t/t3009-ls-files-others-nonsubmodule.sh
new file mode 100755
index 0000000000..cc66a4a14d
--- /dev/null
+++ b/t/t3009-ls-files-others-nonsubmodule.sh
@@ -0,0 +1,21 @@ 
+#!/bin/sh
+
+test_description='test git ls-files --others with non-submodule repositories'
+
+. ./test-lib.sh
+
+test_expect_success 'setup: expected output' '
+	cat >expected <<-EOF
+	expected
+	output
+	EOF
+'
+
+test_expect_success 'ls-files --others handles non-submodule .git' '
+	mkdir not-a-submodule &&
+	echo foo >not-a-submodule/.git &&
+	git ls-files -o >output &&
+	test_cmp expected output
+'
+
+test_done