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

[PATCH v2 00/15] t5520: various test cleanup

From
Denton Liu <liu.denton@gmail.com>
Date
Oct 18, 2019, 22:10 UTC
Message-ID
<cover.1571435195.git.liu.denton@gmail.com>
In-Reply-To
<cover.1571354136.git.liu.denton@gmail.com>

Like earlier patchsets, I want to implement a feature that involves modifications to the test suite. Since that feature will probably take a while to polish up, however, let's clean up the test suite in a separate patchset first so it's not blocked by the feature work.

1/15 is a cleanup to an unrelated test that I found while addressing some of Eric's comments.

2/15 is a general improvement to test_rev_cmp() that will be used later in the series.

Changes since v1:
* Incorporate Eric's feedback
Denton Liu (15):
  t7408: replace `test_must_fail test_path_is_file`
  t: teach test_cmp_rev to accept ! for not-equals
  t5520: improve test style
  t5520: use sq for test case names
  t5520: let sed open its own input
  t5520: replace test -f with test-lib functions
  t5520: remove spaces after redirect operator
  t5520: use test_line_count where possible
  t5520: replace test -{n,z} with test-lib functions
  t5520: use test_cmp_rev where possible
  t5520: test single-line files by git with test_cmp
  t5520: don't put git in upstream of pipe
  t5520: replace subshell cat comparison with test_cmp
  t5520: remove redundant lines in test cases
  t5520: replace `! git` with `test_must_fail git`
 t/t2400-worktree-add.sh             |   4 +-
 t/t3400-rebase.sh                   |   2 +-
 t/t3421-rebase-topology-linear.sh   |   6 +-
 t/t3430-rebase-merges.sh            |   2 +-
 t/t3432-rebase-fast-forward.sh      |   2 +-
 t/t3501-revert-cherry-pick.sh       |   2 +-
 t/t3508-cherry-pick-many-commits.sh |   2 +-
 t/t5520-pull.sh                     | 343 +++++++++++++++++-----------
 t/t7408-submodule-reference.sh      |   2 +-
 t/test-lib-functions.sh             |  13 +-
 10 files changed, 227 insertions(+), 151 deletions(-)
Range-diff against v1:
 -:  ---------- >  1:  987fee4652 t7408: replace `test_must_fail test_path_is_file`
 -:  ---------- >  2:  417e808466 t: teach test_cmp_rev to accept ! for not-equals
 1:  0bc54dd330 =  3:  0a56980857 t5520: improve test style
 2:  a5dee82ecc =  4:  dfa89ba1cb t5520: use sq for test case names
 3:  58cc2fcda3 =  5:  9fac3dff83 t5520: let sed open its own input
 4:  d2946208d3 !  6:  c6ca45eb17 t5520: replace test -f with test_path_is_file
    @@ Metadata
     Author: Denton Liu <liu.denton@gmail.com>
     
      ## Commit message ##
    -    t5520: replace test -f with test_path_is_file
    +    t5520: replace test -f with test-lib functions
     
         Although `test -f` has the same functionality as test_path_is_file(), in
         the case where test_path_is_file() fails, we get much better debugging
    -    information. Replace `test -f` with test_path_is_file so that future
    -    developers will have a better experience debugging these test cases.
    +    information.
    +
    +    Replace `test -f` with test_path_is_file() so that future developers
    +    will have a better experience debugging these test cases.
    +
    +    Also, in the case of `! test -f`, not only should that path not be a
    +    file, it shouldn't exist at all so replace it with
    +    test_path_is_missing().
     
         Signed-off-by: Denton Liu <liu.denton@gmail.com>
     
    @@ t/t5520-pull.sh: test_expect_success 'pulling into void must not create an octop
      		cd cloned-octopus &&
      		test_must_fail git pull .. master master &&
     -		! test -f file
    -+		test_must_fail test_path_is_file file
    ++		test_path_is_missing file
      	)
      '
      
 5:  5b4c1dd291 =  7:  830a8212ae t5520: remove spaces after redirect operator
 6:  26fea15950 =  8:  3d982230be t5520: use test_line_count where possible
 7:  3fc0354c9c !  9:  2bca4f046d t5520: replace test -{n,z} with test-lib functions
    @@ Metadata
      ## Commit message ##
         t5520: replace test -{n,z} with test-lib functions
     
    +    When wrapping a Git command in a subshell within another command, we
    +    throw away the Git command's exit code. In case the Git command fails,
    +    we would like to know about it rather than the failure being silent.
    +    Extract Git commands so that their exit codes are not lost.
    +
         Instead of using `test -n` or `test -z`, replace them respectively with
    -    invocations of test_file_not_empty() and test_must_be_empty().
    +    invocations of test_file_not_empty() and test_must_be_empty() so that we
    +    get better debugging information in the case of a failure.
     
         Signed-off-by: Denton Liu <liu.denton@gmail.com>
     
 8:  f4eb80c9ac ! 10:  1a54db1d5c t5520: use test_cmp_rev where possible
    @@ Commit message
     
                 s/test "$(git rev-parse.* \([^)]*\))" = "$(git rev-parse \([^)]*\))"/test_cmp_rev \1 \2/
                 s/test \([^ ]*\) = "$(git rev-parse.* \([^)]*\))"/test_cmp_rev \1 \2/
    -            s/test "$(git rev-parse.* \([^)]*\))" != "$(git rev-parse.* \([^)]*\))"/test_must_fail test_cmp_rev \1 \2/
    -            s/test \([^ ]*\) != "$(git rev-parse.* \([^)]*\))"/test_must_fail test_cmp_rev \1 \2/
    +            s/test "$(git rev-parse.* \([^)]*\))" != "$(git rev-parse.* \([^)]*\))"/test_cmp_rev ! \1 \2/
    +            s/test \([^ ]*\) != "$(git rev-parse.* \([^)]*\))"/test_cmp_rev ! \1 \2/
     
         Signed-off-by: Denton Liu <liu.denton@gmail.com>
     
    @@ t/t5520-pull.sh: test_expect_success 'branch.to-rebase.rebase should override pu
      	test_config branch.to-rebase.rebase false &&
      	git pull . copy &&
     -	test "$(git rev-parse HEAD^)" != "$(git rev-parse copy)" &&
    -+	test_must_fail test_cmp_rev HEAD^ copy &&
    ++	test_cmp_rev ! HEAD^ copy &&
      	test new = "$(git show HEAD:file2)"
      '
      
    @@ t/t5520-pull.sh: test_expect_success 'pull --rebase dies early with dirty workin
      	git checkout HEAD -- file &&
      	git pull &&
     -	test "$COPY" != "$(git rev-parse --verify me/copy)"
    -+	test_must_fail test_cmp_rev "$COPY" me/copy
    ++	test_cmp_rev ! "$COPY" me/copy
      '
      
      test_expect_success 'pull --rebase works on branch yet to be born' '
 9:  bd3ec4239c ! 11:  52cf4f0d0f t5520: test single-line files by git with test_cmp
    @@ Commit message
                 s/\(\s*\)test \([^ ]*\) = "$(\(git [^)]*\))"/\1echo \2 >expect \&\&\n\1\3 >actual \&\&\n\1test_cmp expect actual/
                 s/\(\s*\)test "$(\(git [^)]*\))" = \([^ ]*\)/\1echo \3 >expect \&\&\n\1\2 >actual \&\&\n\1test_cmp expect actual/
     
    +    A future patch will clean up situations where we have multiple duplicate
    +    statements within a test case. This is done to keep this patch purely
    +    mechanical.
    +
         Signed-off-by: Denton Liu <liu.denton@gmail.com>
     
      ## t/t5520-pull.sh ##
    @@ t/t5520-pull.sh: test_expect_success 'branch.to-rebase.rebase' '
     @@ t/t5520-pull.sh: test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
      	test_config branch.to-rebase.rebase false &&
      	git pull . copy &&
    - 	test_must_fail test_cmp_rev HEAD^ copy &&
    + 	test_cmp_rev ! HEAD^ copy &&
     -	test new = "$(git show HEAD:file2)"
     +	echo new >expect &&
     +	git show HEAD:file2 >actual &&
10:  61b4df0f7c = 12:  0cfabb201c t5520: don't put git in upstream of pipe
11:  f3429bbb57 ! 13:  b2d0ce21c8 t5520: replace subshell cat comparison with test_cmp
    @@ Commit message
                 s/\(\s*\)test \([^=]*\)= "$(cat \([^)]*\))"/\1echo \2>expect \&\&\n\1test_cmp expect \3/
                 s/\(\s*\)test "$(cat \([^)]*\))" = \([^&]*\)\( &&\)\?$/\1echo \3 >expect \&\&\n\1test_cmp expect \2\4/
     
    +    A future patch will clean up situations where we have multiple duplicate
    +    statements within a test case. This is done to keep this patch purely
    +    mechanical.
    +
         Signed-off-by: Denton Liu <liu.denton@gmail.com>
     
      ## t/t5520-pull.sh ##
 -:  ---------- > 14:  5aac40a029 t5520: remove redundant lines in test cases
12:  3e6c591b2b = 15:  2c0d3ac416 t5520: replace `! git` with `test_must_fail git`
-- 
2.23.0.897.g0a19638b1e
Previous: Denton LiuNext: Denton Liu
Message 22 of 116 in “t5520: various test cleanup”
  1. 00/12 t5520: various test cleanupDenton Liu, Oct 17, 2019
  2. 01/12 t5520: improve test styleDenton Liu, Oct 17, 2019
  3. 02/12 t5520: use sq for test case namesDenton Liu, Oct 17, 2019
  4. 03/12 t5520: let sed open its own inputDenton Liu, Oct 17, 2019
  5. 05/12 t5520: remove spaces after redirect operatorDenton Liu, Oct 17, 2019
  6. 04/12 t5520: replace test -f with test_path_is_fileDenton Liu, Oct 17, 2019
  7. Eric SunshineOct 17, 2019
  8. 5/12 t5520: replace test -f with test-lib functionsDenton Liu, Oct 17, 2019
  9. Eric SunshineOct 18, 2019
  10. 06/12 t5520: use test_line_count where possibleDenton Liu, Oct 17, 2019
  11. 07/12 t5520: replace test -{n,z} with test-lib functionsDenton Liu, Oct 17, 2019
  12. Eric SunshineOct 17, 2019
  13. 08/12 t5520: use test_cmp_rev where possibleDenton Liu, Oct 17, 2019
  14. Eric SunshineOct 17, 2019
  15. Denton LiuOct 18, 2019
  16. Eric SunshineOct 23, 2019
  17. 09/12 t5520: test single-line files by git with test_cmpDenton Liu, Oct 17, 2019
  18. Eric SunshineOct 17, 2019
  19. 10/12 t5520: don't put git in upstream of pipeDenton Liu, Oct 17, 2019
  20. 11/12 t5520: replace subshell cat comparison with test_cmpDenton Liu, Oct 17, 2019
  21. 12/12 t5520: replace `! git` with `test_must_fail git`Denton Liu, Oct 17, 2019
  22. 00/15 t5520: various test cleanupDenton Liu, Oct 18, 2019
  23. 01/15 t7408: replace `test_must_fail test_path_is_file`Denton Liu, Oct 18, 2019
  24. Johannes SixtOct 19, 2019
  25. 09/15 t5520: replace test -{n,z} with test-lib functionsDenton Liu, Oct 18, 2019
  26. 11/15 t5520: test single-line files by git with test_cmpDenton Liu, Oct 18, 2019
  27. 06/15 t5520: replace test -f with test-lib functionsDenton Liu, Oct 18, 2019
  28. 12/15 t5520: don't put git in upstream of pipeDenton Liu, Oct 18, 2019
  29. 14/15 t5520: remove redundant lines in test casesDenton Liu, Oct 18, 2019
  30. 15/15 t5520: replace `! git` with `test_must_fail git`Denton Liu, Oct 18, 2019
  31. 13/15 t5520: replace subshell cat comparison with test_cmpDenton Liu, Oct 18, 2019
  32. 10/15 t5520: use test_cmp_rev where possibleDenton Liu, Oct 18, 2019
  33. 08/15 t5520: use test_line_count where possibleDenton Liu, Oct 18, 2019
  34. 07/15 t5520: remove spaces after redirect operatorDenton Liu, Oct 18, 2019
  35. 05/15 t5520: let sed open its own inputDenton Liu, Oct 18, 2019
  36. 04/15 t5520: use sq for test case namesDenton Liu, Oct 18, 2019
  37. 03/15 t5520: improve test styleDenton Liu, Oct 18, 2019
  38. 02/15 t: teach test_cmp_rev to accept ! for not-equalsDenton Liu, Oct 18, 2019
  39. SZEDER GáborOct 18, 2019
  40. Denton LiuOct 18, 2019
  41. 00/14 t5520: various test cleanupDenton Liu, Oct 22, 2019
  42. 01/14 t: teach test_cmp_rev to accept ! for not-equalsDenton Liu, Oct 22, 2019
  43. 02/14 t5520: improve test styleDenton Liu, Oct 22, 2019
  44. 03/14 t5520: use sq for test case namesDenton Liu, Oct 22, 2019
  45. 04/14 t5520: let sed open its own inputDenton Liu, Oct 22, 2019
  46. 05/14 t5520: replace test -f with test-lib functionsDenton Liu, Oct 22, 2019
  47. 06/14 t5520: remove spaces after redirect operatorDenton Liu, Oct 22, 2019
  48. 07/14 t5520: use test_line_count where possibleDenton Liu, Oct 22, 2019
  49. 08/14 t5520: replace test -{n,z} with test-lib functionsDenton Liu, Oct 22, 2019
  50. 09/14 t5520: use test_cmp_rev where possibleDenton Liu, Oct 22, 2019
  51. 10/14 t5520: test single-line files by git with test_cmpDenton Liu, Oct 22, 2019
  52. 11/14 t5520: don't put git in upstream of pipeDenton Liu, Oct 22, 2019
  53. 12/14 t5520: replace subshell cat comparison with test_cmpDenton Liu, Oct 22, 2019
  54. 13/14 t5520: remove redundant lines in test casesDenton Liu, Oct 22, 2019
  55. 14/14 t5520: replace `! git` with `test_must_fail git`Denton Liu, Oct 22, 2019
  56. Denton LiuOct 24, 2019
  57. Junio C HamanoOct 25, 2019
  58. Denton LiuNov 4, 2019
  59. Junio C HamanoNov 6, 2019
  60. 00/14 t5520: various test cleanupDenton Liu, Nov 7, 2019
  61. 01/14 t: teach test_cmp_rev to accept ! for not-equalsDenton Liu, Nov 7, 2019
  62. Junio C HamanoNov 8, 2019
  63. Denton LiuNov 8, 2019
  64. Junio C HamanoNov 8, 2019
  65. Denton LiuNov 8, 2019
  66. Junio C HamanoNov 10, 2019
  67. 02/14 t5520: improve test styleDenton Liu, Nov 7, 2019
  68. 03/14 t5520: use sq for test case namesDenton Liu, Nov 7, 2019
  69. 04/14 t5520: let sed open its own inputDenton Liu, Nov 7, 2019
  70. 05/14 t5520: replace test -f with test-lib functionsDenton Liu, Nov 7, 2019
  71. 06/14 t5520: remove spaces after redirect operatorDenton Liu, Nov 7, 2019
  72. 07/14 t5520: use test_line_count where possibleDenton Liu, Nov 7, 2019
  73. 08/14 t5520: replace test -{n,z} with test-lib functionsDenton Liu, Nov 7, 2019
  74. 09/14 t5520: use test_cmp_rev where possibleDenton Liu, Nov 7, 2019
  75. 10/14 t5520: test single-line files by git with test_cmpDenton Liu, Nov 7, 2019
  76. 11/14 t5520: don't put git in upstream of pipeDenton Liu, Nov 7, 2019
  77. 12/14 t5520: replace subshell cat comparison with test_cmpDenton Liu, Nov 7, 2019
  78. 13/14 t5520: remove redundant lines in test casesDenton Liu, Nov 7, 2019
  79. 14/14 t5520: replace `! git` with `test_must_fail git`Denton Liu, Nov 7, 2019
  80. 00/14 t5520: various test cleanupDenton Liu, Nov 12, 2019
  81. 01/14 t: teach test_cmp_rev to accept ! for not-equalsDenton Liu, Nov 12, 2019
  82. Junio C HamanoNov 12, 2019
  83. fixup! t: teach test_cmp_rev to accept ! for not-equalsDenton Liu, Nov 12, 2019
  84. 02/14 t5520: improve test styleDenton Liu, Nov 12, 2019
  85. 03/14 t5520: use sq for test case namesDenton Liu, Nov 12, 2019
  86. 04/14 t5520: let sed open its own inputDenton Liu, Nov 12, 2019
  87. 05/14 t5520: replace test -f with test-lib functionsDenton Liu, Nov 12, 2019
  88. 06/14 t5520: remove spaces after redirect operatorDenton Liu, Nov 12, 2019
  89. 07/14 t5520: use test_line_count where possibleDenton Liu, Nov 12, 2019
  90. 08/14 t5520: replace test -{n,z} with test-lib functionsDenton Liu, Nov 12, 2019
  91. 09/14 t5520: use test_cmp_rev where possibleDenton Liu, Nov 12, 2019
  92. 10/14 t5520: test single-line files by git with test_cmpDenton Liu, Nov 12, 2019
  93. Junio C HamanoNov 12, 2019
  94. Denton LiuNov 12, 2019
  95. 11/14 t5520: don't put git in upstream of pipeDenton Liu, Nov 12, 2019
  96. 12/14 t5520: replace subshell cat comparison with test_cmpDenton Liu, Nov 12, 2019
  97. 13/14 t5520: remove redundant lines in test casesDenton Liu, Nov 12, 2019
  98. 14/14 t5520: replace `! git` with `test_must_fail git`Denton Liu, Nov 12, 2019
  99. 00/14 t5520: various test cleanupDenton Liu, Nov 12, 2019
  100. 01/14 t: teach test_cmp_rev to accept ! for not-equalsDenton Liu, Nov 12, 2019
  101. Junio C HamanoNov 13, 2019
  102. Denton LiuNov 14, 2019
  103. 02/14 t5520: improve test styleDenton Liu, Nov 12, 2019
  104. 03/14 t5520: use sq for test case namesDenton Liu, Nov 12, 2019
  105. 04/14 t5520: let sed open its own inputDenton Liu, Nov 12, 2019
  106. 05/14 t5520: replace test -f with test-lib functionsDenton Liu, Nov 12, 2019
  107. 06/14 t5520: remove spaces after redirect operatorDenton Liu, Nov 12, 2019
  108. 07/14 t5520: use test_line_count where possibleDenton Liu, Nov 12, 2019
  109. 08/14 t5520: replace test -{n,z} with test-lib functionsDenton Liu, Nov 12, 2019
  110. 09/14 t5520: use test_cmp_rev where possibleDenton Liu, Nov 12, 2019
  111. 10/14 t5520: test single-line files by git with test_cmpDenton Liu, Nov 12, 2019
  112. 11/14 t5520: don't put git in upstream of pipeDenton Liu, Nov 12, 2019
  113. 12/14 t5520: replace $(cat ...) comparison with test_cmpDenton Liu, Nov 12, 2019
  114. 13/14 t5520: remove redundant lines in test casesDenton Liu, Nov 12, 2019
  115. 14/14 t5520: replace `! git` with `test_must_fail git`Denton Liu, Nov 12, 2019
  116. Junio C HamanoNov 13, 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.