]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3000: add more testcases testing a variety of ls-files issues
authorElijah Newren <newren@gmail.com>
Wed, 1 Apr 2020 04:17:36 +0000 (04:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Apr 2020 18:10:38 +0000 (11:10 -0700)
This adds seven new ls-files tests.  While currently all seven test
pass, my earlier rounds of restructuring dir.c to replace an exponential
algorithm with a linear one passed all the tests in the testsuite but
failed six of these seven new tests.  Add these tests to increase our
case coverage.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3000-ls-files-others.sh

index 0aefadacb05329d4f9b9ddf11fcbcc66e91158c8..ffdfb16f580571a50e542b8ddb50915db8ad0584 100755 (executable)
@@ -91,4 +91,125 @@ test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' '
        test_cmp expect actual
 '
 
+test_expect_success 'setup nested pathspec search' '
+       test_create_repo nested &&
+       (
+               cd nested &&
+
+               mkdir -p partially_tracked/untracked_dir &&
+               > partially_tracked/content &&
+               > partially_tracked/untracked_dir/file &&
+
+               mkdir -p untracked/deep &&
+               > untracked/deep/path &&
+               > untracked/deep/foo.c &&
+
+               git add partially_tracked/content
+       )
+'
+
+test_expect_success 'ls-files -o --directory with single deep dir pathspec' '
+       (
+               cd nested &&
+
+               git ls-files -o --directory untracked/deep/ >actual &&
+
+               cat <<-EOF >expect &&
+               untracked/deep/
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ls-files -o --directory with multiple dir pathspecs' '
+       (
+               cd nested &&
+
+               git ls-files -o --directory partially_tracked/ untracked/ >actual &&
+
+               cat <<-EOF >expect &&
+               partially_tracked/untracked_dir/
+               untracked/
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ls-files -o --directory with mix dir/file pathspecs' '
+       (
+               cd nested &&
+
+               git ls-files -o --directory partially_tracked/ untracked/deep/path >actual &&
+
+               cat <<-EOF >expect &&
+               partially_tracked/untracked_dir/
+               untracked/deep/path
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ls-files --o --directory with glob filetype match' '
+       (
+               cd nested &&
+
+               # globs kinda defeat --directory, but only for that pathspec
+               git ls-files --others --directory partially_tracked "untracked/*.c" >actual &&
+
+               cat <<-EOF >expect &&
+               partially_tracked/untracked_dir/
+               untracked/deep/foo.c
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ls-files --o --directory with mix of tracked states' '
+       (
+               cd nested &&
+
+               # globs kinda defeat --directory, but only for that pathspec
+               git ls-files --others --directory partially_tracked/ "untracked/?*" >actual &&
+
+               cat <<-EOF >expect &&
+               partially_tracked/untracked_dir/
+               untracked/deep/
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ls-files --o --directory with glob filetype match only' '
+       (
+               cd nested &&
+
+               git ls-files --others --directory "untracked/*.c" >actual &&
+
+               cat <<-EOF >expect &&
+               untracked/deep/foo.c
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'ls-files --o --directory to get immediate paths under one dir only' '
+       (
+               cd nested &&
+
+               git ls-files --others --directory "untracked/?*" >actual &&
+
+               cat <<-EOF >expect &&
+               untracked/deep/
+               EOF
+
+               test_cmp expect actual
+       )
+'
+
 test_done