# [PATCH] t0000: cover GIT_SKIP_TESTS blindspot

2 messages from 2019-10-02 to 2019-10-08. Participants: Denton Liu.
Thread: https://gitlist.dev/t/51954

## Denton Liu, 2019-10-02 06:14

Subject: [PATCH] t0000: cover GIT_SKIP_TESTS blindspot
Message-ID: <08273a0d0deae610b93d7f5eb28b0df5f978bf20.1569996425.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/08273a0d0deae610b93d7f5eb28b0df5f978bf20.1569996425.git.liu.denton%40gmail.com

```
Currently, the tests for GIT_SKIP_TESTS do not cover the situation where
we skip an entire test suite. Add a test case so we cover this
blindspot.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
This patch was created as a result of me teaching test-lib.sh to
recognise GIT_RUN_TESTS as a variable, similar to the --run option. That
patch is polished up and ready to go but I realised that running
something like

	make T=t4???-*.sh -j

covers all the use cases I was thinking of so I'm abandoning it. If
anyone has any use for that patch, though, let me know and I can send it
in.

 t/t0000-basic.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 4c01f60dd3..1c5c75920e 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -391,6 +391,23 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' "
 	)
 "
 
+test_expect_success 'GIT_SKIP_TESTS entire suite' "
+	(
+		GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS &&
+		run_sub_test_lib_test git-skip-tests-entire-suite \
+			'GIT_SKIP_TESTS entire suite' <<-\\EOF &&
+		for i in 1 2 3
+		do
+			test_expect_success \"passing test #\$i\" 'true'
+		done
+		test_done
+		EOF
+		check_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF
+		> 1..0 # SKIP skip all tests in git
+		EOF
+	)
+"
+
 test_expect_success '--run basic' "
 	run_sub_test_lib_test run-basic \
 		'--run basic' --run='1 3 5' <<-\\EOF &&
-- 
2.23.0.248.g3a9dd8fb08


```

## Denton Liu, 2019-10-08 09:22

Subject: [PATCH v2] t0000: cover GIT_SKIP_TESTS blindspots
Message-ID: <b5f3af8a630aec2d8bffe8e76f1d113171eda250.1570526491.git.liu.denton@gmail.com>
URL: https://gitlist.dev/e/b5f3af8a630aec2d8bffe8e76f1d113171eda250.1570526491.git.liu.denton%40gmail.com
In-Reply-To: <08273a0d0deae610b93d7f5eb28b0df5f978bf20.1569996425.git.liu.denton@gmail.com>

```
Currently, the tests for GIT_SKIP_TESTS do not cover the situation where
we skip an entire test suite. The tests also do not cover the situation
where we have GIT_SKIP_TESTS defined but the test suite does not match.

Add two test cases so we cover this blindspot.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
Changes since v1:

* Added another test case to cover the blindspot where GIT_SKIP_TESTS is
  defined but the test suite does not match.

Range-diff against v1:
1:  08273a0d0d ! 1:  b5f3af8a63 t0000: cover GIT_SKIP_TESTS blindspot
    @@ Metadata
     Author: Denton Liu <liu.denton@gmail.com>
     
      ## Commit message ##
    -    t0000: cover GIT_SKIP_TESTS blindspot
    +    t0000: cover GIT_SKIP_TESTS blindspots
     
         Currently, the tests for GIT_SKIP_TESTS do not cover the situation where
    -    we skip an entire test suite. Add a test case so we cover this
    -    blindspot.
    +    we skip an entire test suite. The tests also do not cover the situation
    +    where we have GIT_SKIP_TESTS defined but the test suite does not match.
    +
    +    Add two test cases so we cover this blindspot.
     
      ## t/t0000-basic.sh ##
     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS sh pattern' "
    @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS sh pattern' "
     +		EOF
     +	)
     +"
    ++
    ++test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' "
    ++	(
    ++		GIT_SKIP_TESTS='notgit' && export GIT_SKIP_TESTS &&
    ++		run_sub_test_lib_test git-skip-tests-unmatched-suite \
    ++			'GIT_SKIP_TESTS does not skip unmatched suite' <<-\\EOF &&
    ++		for i in 1 2 3
    ++		do
    ++			test_expect_success \"passing test #\$i\" 'true'
    ++		done
    ++		test_done
    ++		EOF
    ++		check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF
    ++		> ok 1 - passing test #1
    ++		> ok 2 - passing test #2
    ++		> ok 3 - passing test #3
    ++		> # passed all 3 test(s)
    ++		> 1..3
    ++		EOF
    ++	)
    ++"
     +
      test_expect_success '--run basic' "
      	run_sub_test_lib_test run-basic \

 t/t0000-basic.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 4c01f60dd3..4d3f7ba295 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -391,6 +391,44 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' "
 	)
 "
 
+test_expect_success 'GIT_SKIP_TESTS entire suite' "
+	(
+		GIT_SKIP_TESTS='git' && export GIT_SKIP_TESTS &&
+		run_sub_test_lib_test git-skip-tests-entire-suite \
+			'GIT_SKIP_TESTS entire suite' <<-\\EOF &&
+		for i in 1 2 3
+		do
+			test_expect_success \"passing test #\$i\" 'true'
+		done
+		test_done
+		EOF
+		check_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF
+		> 1..0 # SKIP skip all tests in git
+		EOF
+	)
+"
+
+test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' "
+	(
+		GIT_SKIP_TESTS='notgit' && export GIT_SKIP_TESTS &&
+		run_sub_test_lib_test git-skip-tests-unmatched-suite \
+			'GIT_SKIP_TESTS does not skip unmatched suite' <<-\\EOF &&
+		for i in 1 2 3
+		do
+			test_expect_success \"passing test #\$i\" 'true'
+		done
+		test_done
+		EOF
+		check_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF
+		> ok 1 - passing test #1
+		> ok 2 - passing test #2
+		> ok 3 - passing test #3
+		> # passed all 3 test(s)
+		> 1..3
+		EOF
+	)
+"
+
 test_expect_success '--run basic' "
 	run_sub_test_lib_test run-basic \
 		'--run basic' --run='1 3 5' <<-\\EOF &&
-- 
2.23.0.248.g3a9dd8fb08


```
