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

[PATCH 1/2] test-lib: prevent misuses of --invert-exit-code

From
Rubén Justo <rjusto@gmail.com>
Date
Sep 9, 2023, 23:08 UTC
Message-ID
<1a60a1ca-0ef0-ecf5-d0aa-a28d7c148a82@gmail.com>
In-Reply-To
<68522960-edda-26d3-ddca-cee63f2d859e@gmail.com>

GIT_TEST_PASSING_SANITIZE_LEAK=true and GIT_TEST_SANITIZE_LEAK_LOG=true use internnlly the --invert-exit-code machinery. Therefore if the user wants to use --invert-exit-code in combination with them, the result will be confusing.

For the same reason, we are already using BAIL_OUT if the user tries to combine GIT_TEST_PASSING_SANITIZE_LEAK=check with --invert-exit-code.

Let's do the same for GIT_TEST_PASSING_SANITIZE_LEAK=true and GIT_TEST_SANITIZE_LEAK_LOG=true.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 t/test-lib.sh | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 293caf0f20..88a34fba67 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1557,15 +1557,25 @@ then
 			say "in GIT_TEST_PASSING_SANITIZE_LEAK=check mode, setting --invert-exit-code for TEST_PASSES_SANITIZE_LEAK != true"
 			invert_exit_code=t
 		fi
-	elif test -z "$passes_sanitize_leak" &&
-	     test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
+	elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
 	then
-		skip_all="skipping $this_test under GIT_TEST_PASSING_SANITIZE_LEAK=true"
-		test_done
+		if test -n "$invert_exit_code"
+		then
+			BAIL_OUT "cannot use --invert-exit-code under GIT_TEST_PASSING_SANITIZE_LEAK=true"
+		elif test -z "$passes_sanitize_leak"
+		then
+			skip_all="skipping $this_test under GIT_TEST_PASSING_SANITIZE_LEAK=true"
+			test_done
+		fi
 	fi
 
 	if test_bool_env GIT_TEST_SANITIZE_LEAK_LOG false
 	then
+		if test -n "$invert_exit_code"
+		then
+			BAIL_OUT "cannot use --invert-exit-code and GIT_TEST_SANITIZE_LEAK_LOG=true"
+		fi
+
 		if ! mkdir -p "$TEST_RESULTS_SAN_DIR"
 		then
 			BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR"
-- 
2.40.1
Previous: Rubén JustoNext: Eric Sunshine
Message 2 of 16 in “fix GIT_TEST_SANITIZE_LEAK_LOG=true”
  1. 0/2 fix GIT_TEST_SANITIZE_LEAK_LOG=trueRubén Justo, Sep 9, 2023
  2. 1/2 test-lib: prevent misuses of --invert-exit-codeRubén Justo, Sep 9, 2023
  3. Eric SunshineSep 10, 2023
  4. Rubén JustoSep 10, 2023
  5. Jeff KingSep 12, 2023
  6. Rubén JustoSep 15, 2023
  7. 2/2 test-lib: fix GIT_TEST_SANITIZE_LEAK_LOGRubén Justo, Sep 9, 2023
  8. Jeff KingSep 12, 2023
  9. Rubén JustoSep 15, 2023
  10. Jeff KingSep 15, 2023
  11. Junio C HamanoSep 15, 2023
  12. Jeff KingSep 16, 2023
  13. Junio C HamanoSep 15, 2023
  14. test-lib: fix GIT_TEST_SANITIZE_LEAK_LOGRubén Justo, Sep 22, 2023
  15. Jeff KingSep 23, 2023
  16. Rubén JustoSep 23, 2023

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.