git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] test-lib: don't check prereqs of test cases that won't be run anyway

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 12, 2019, 12:24 UTC
Message-ID
<20191112122438.17057-1-szeder.dev@gmail.com>

With './t1234-foo.sh -r 5,6' we can run only specific test cases in a test script, but our test framwork still evaluates all lazy prereqs that the excluded test cases might depend on. This is unnecessary and produces verbose and trace output that can be distracting. This has been an issue ever since the '-r|--run=' options were introduced in 0445e6f0a1 (test-lib: '--run' to run only specific tests, 2014-04-30), because that commit added the check of the list of test cases specified with '-r' after evaluating the prereqs.

Avoid this unnecessary prereq evaluation by checking the list of test cases specified with '-r' before looking at the prereqs.

Note that GIT_SKIP_TESTS has always been checked before the prereqs, so prereqs necessary for tests skipped that way were not evaluated.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
Following up on:
  https://public-inbox.org/git/20190923165828.GA27068@szeder.dev/
 t/test-lib.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index e06fa02a0e..24b541f494 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1000,6 +1000,12 @@ test_skip () {
 		to_skip=t
 		skipped_reason="GIT_SKIP_TESTS"
 	fi
+	if test -z "$to_skip" && test -n "$run_list" &&
+	   ! match_test_selector_list '--run' $test_count "$run_list"
+	then
+		to_skip=t
+		skipped_reason="--run"
+	fi
 	if test -z "$to_skip" && test -n "$test_prereq" &&
 	   ! test_have_prereq "$test_prereq"
 	then
@@ -1012,12 +1018,6 @@ test_skip () {
 		fi
 		skipped_reason="missing $missing_prereq${of_prereq}"
 	fi
-	if test -z "$to_skip" && test -n "$run_list" &&
-		! match_test_selector_list '--run' $test_count "$run_list"
-	then
-		to_skip=t
-		skipped_reason="--run"
-	fi
 
 	case "$to_skip" in
 	t)
-- 
2.24.0.388.gde53c094ea
Next: Jeff King
Message 1 of 3 in “test-lib: don't check prereqs of test cases that won't be run anyway”
  1. test-lib: don't check prereqs of test cases that won't be run anywaySZEDER Gábor, Nov 12, 2019
  2. Jeff KingNov 12, 2019
  3. Johannes SchindelinNov 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.