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

[PATCH v3 02/15] t0000: replace test_must_fail with run_sub_test_lib_test_err()

From
Denton Liu <liu.denton@gmail.com>
Date
Dec 20, 2019, 18:15 UTC
Message-ID
<51a2226726c941c1229e6aafa355376fdb6c61c5.1576865664.git.liu.denton@gmail.com>
In-Reply-To
<cover.1576865663.git.liu.denton@gmail.com>

The test_must_fail function should only be used for git commands since we should assume that external commands work sanely. We use test_must_fail to test run_sub_test_lib_test() but that function does not invoke any git commands internally. Even better, we have a function that's exactly meant to be used when we expect to have a failing test suite: run_sub_test_lib_test_err()!

Replace `test_must_fail run_sub_test_lib_test` with `run_sub_test_lib_test_err`.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t0000-basic.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 8a81a249d0..3e440c078d 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -155,7 +155,7 @@ test_expect_success 'pretend we have a fully passing test suite' "
 "
 
 test_expect_success 'pretend we have a partially passing test suite' "
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		partial-pass '2/3 tests passing' <<-\\EOF &&
 	test_expect_success 'passing test #1' 'true'
 	test_expect_success 'failing test #2' 'false'
@@ -219,7 +219,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su
 "
 
 test_expect_success 'pretend we have a pass, fail, and known breakage' "
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		mixed-results1 'mixed results #1' <<-\\EOF &&
 	test_expect_success 'passing test' 'true'
 	test_expect_success 'failing test' 'false'
@@ -238,7 +238,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' "
 "
 
 test_expect_success 'pretend we have a mix of all possible results' "
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		mixed-results2 'mixed results #2' <<-\\EOF &&
 	test_expect_success 'passing test' 'true'
 	test_expect_success 'passing test' 'true'
@@ -274,7 +274,7 @@ test_expect_success 'pretend we have a mix of all possible results' "
 "
 
 test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		t1234-verbose "test verbose" --verbose <<-\EOF &&
 	test_expect_success "passing test" true
 	test_expect_success "test with output" "echo foo"
@@ -301,7 +301,7 @@ test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
 '
 
 test_expect_success 'test --verbose-only' '
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		t2345-verbose-only-2 "test verbose-only=2" \
 		--verbose-only=2 <<-\EOF &&
 	test_expect_success "passing test" true
@@ -834,7 +834,7 @@ then
 fi
 
 test_expect_success 'tests clean up even on failures' "
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF &&
 	test_expect_success 'tests clean up even after a failure' '
 		touch clean-after-failure &&
@@ -863,7 +863,7 @@ test_expect_success 'tests clean up even on failures' "
 "
 
 test_expect_success 'test_atexit is run' "
-	test_must_fail run_sub_test_lib_test \
+	run_sub_test_lib_test_err \
 		atexit-cleanup 'Run atexit commands' -i <<-\\EOF &&
 	test_expect_success 'tests clean up even after a failure' '
 		> ../../clean-atexit &&
-- 
2.24.1.703.g2f499f1283
Previous: Denton LiuNext: Denton Liu
Message 51 of 64 in “t: replace incorrect test_must_fail usage (part 1)”
  1. 00/15 t: replace incorrect test_must_fail usage (part 1)Denton Liu, Dec 17, 2019
  2. 01/15 test-lib-functions: introduce test_non_git_might_fail()Denton Liu, Dec 17, 2019
  3. 03/15 t0000: replace test_must_fail with ! for run_sub_test_lib_test()Denton Liu, Dec 17, 2019
  4. Johannes SixtDec 17, 2019
  5. 05/15 t0003: use test_must_be_empty()Denton Liu, Dec 17, 2019
  6. 04/15 t0003: use named parameters in attr_check()Denton Liu, Dec 17, 2019
  7. Junio C HamanoDec 17, 2019
  8. Eric SunshineDec 17, 2019
  9. 07/15 t0020: drop redirections to /dev/nullDenton Liu, Dec 17, 2019
  10. Eric SunshineDec 17, 2019
  11. 06/15 t0003: don't use `test_must_fail attr_check`Denton Liu, Dec 17, 2019
  12. Junio C HamanoDec 17, 2019
  13. 08/15 t0020: s/test_must_fail has_cr/! has_cr/Denton Liu, Dec 17, 2019
  14. Eric SunshineDec 17, 2019
  15. 11/15 t1307: reorder `nongit test_must_fail`Denton Liu, Dec 17, 2019
  16. 10/15 t1306: convert `test_might_fail rm` to `rm -f`Denton Liu, Dec 17, 2019
  17. Junio C HamanoDec 17, 2019
  18. 09/15 t0020: use ! check_packed_refs_markedDenton Liu, Dec 17, 2019
  19. 13/15 t1409: use test_path_is_missing()Denton Liu, Dec 17, 2019
  20. Junio C HamanoDec 17, 2019
  21. 14/15 t1501: remove use of `test_might_fail cp`Denton Liu, Dec 17, 2019
  22. Eric SunshineDec 17, 2019
  23. 15/15 t1507: teach full_name() to accept `!` argDenton Liu, Dec 17, 2019
  24. Eric SunshineDec 17, 2019
  25. 12/15 t1409: let sed open its own filesDenton Liu, Dec 17, 2019
  26. Junio C HamanoDec 17, 2019
  27. 02/15 t/lib-git-p4: use test_path_is_missing()Denton Liu, Dec 17, 2019
  28. Junio C HamanoDec 17, 2019
  29. 00/16 t: replace incorrect test_must_fail usage (part 1)Denton Liu, Dec 19, 2019
  30. 01/16 test-lib-functions: introduce test_non_git_might_fail()Denton Liu, Dec 19, 2019
  31. 02/16 t/lib-git-p4: use test_path_is_missing()Denton Liu, Dec 19, 2019
  32. 06/16 t0003: don't use `test_must_fail attr_check`Denton Liu, Dec 19, 2019
  33. 07/16 t0020: don't use `test_must_fail has_cr`Denton Liu, Dec 19, 2019
  34. 04/16 t0003: use named parameters in attr_check()Denton Liu, Dec 19, 2019
  35. 03/16 t0000: replace test_must_fail with run_sub_test_lib_test_err()Denton Liu, Dec 19, 2019
  36. 10/16 t1307: reorder `nongit test_must_fail`Denton Liu, Dec 19, 2019
  37. 11/16 t1409: let sed open its own input fileDenton Liu, Dec 19, 2019
  38. 12/16 t1409: use test_path_is_missing()Denton Liu, Dec 19, 2019
  39. 09/16 t1306: convert `test_might_fail rm` to `rm -f`Denton Liu, Dec 19, 2019
  40. 08/16 t0020: use ! check_packed_refs_markedDenton Liu, Dec 19, 2019
  41. 05/16 t0003: use test_must_be_empty()Denton Liu, Dec 19, 2019
  42. 13/16 t1501: remove use of `test_might_fail cp`Denton Liu, Dec 19, 2019
  43. Eric SunshineDec 19, 2019
  44. Denton LiuDec 19, 2019
  45. Eric SunshineDec 20, 2019
  46. 14/16 t1507: stop losing return codes of git commandsDenton Liu, Dec 19, 2019
  47. 16/16 t1507: inline full_name()Denton Liu, Dec 19, 2019
  48. 15/16 t1507: run commands within test_expect_successDenton Liu, Dec 19, 2019
  49. 00/15 t: replace incorrect test_must_fail usage (part 1)Denton Liu, Dec 20, 2019
  50. 01/15 t/lib-git-p4: use test_path_is_missing()Denton Liu, Dec 20, 2019
  51. 02/15 t0000: replace test_must_fail with run_sub_test_lib_test_err()Denton Liu, Dec 20, 2019
  52. 03/15 t0003: use named parameters in attr_check()Denton Liu, Dec 20, 2019
  53. 04/15 t0003: use test_must_be_empty()Denton Liu, Dec 20, 2019
  54. 06/15 t0020: don't use `test_must_fail has_cr`Denton Liu, Dec 20, 2019
  55. 05/15 t0003: don't use `test_must_fail attr_check`Denton Liu, Dec 20, 2019
  56. 08/15 t1306: convert `test_might_fail rm` to `rm -f`Denton Liu, Dec 20, 2019
  57. 07/15 t0020: use ! check_packed_refs_markedDenton Liu, Dec 20, 2019
  58. 11/15 t1409: use test_path_is_missing()Denton Liu, Dec 20, 2019
  59. 10/15 t1409: let sed open its own input fileDenton Liu, Dec 20, 2019
  60. 12/15 t1501: remove use of `test_might_fail cp`Denton Liu, Dec 20, 2019
  61. 13/15 t1507: stop losing return codes of git commandsDenton Liu, Dec 20, 2019
  62. 09/15 t1307: reorder `nongit test_must_fail`Denton Liu, Dec 20, 2019
  63. 14/15 t1507: run commands within test_expect_successDenton Liu, Dec 20, 2019
  64. 15/15 t1507: inline full_name()Denton Liu, Dec 20, 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.