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

[PATCHv4 0/5] Simple fixes to t7406

From
Elijah Newren <newren@gmail.com>
Date
Aug 8, 2018, 16:31 UTC
Message-ID
<20180808163107.12329-1-newren@gmail.com>
In-Reply-To
<20180807164905.3859-1-newren@gmail.com>
Changes since v3, all suggested/endorsed by Junio (range-diff at the end):
  - Moved the actual fix from being last patch in the series to the first
    (other patches in this series are just test code cleanups)
  - Anchored regexes to avoid matching another filename as a substring
  - Add test_path_exists() to test-lib-function.sh and use it (we had
    test_path_is_dir, test_path_is_file, and test_path_is_missing, but
    not simple test_path_exists)
Elijah Newren (5):
  t7406: fix call that was failing for the wrong reason
  t7406: simplify by using diff --name-only instead of diff --raw
  t7406: avoid having git commands upstream of a pipe
  t7406: prefer test_* helper functions to test -[feds]
  t7406: avoid using test_must_fail for commands other than git
 t/t7406-submodule-update.sh | 37 +++++++++++++++++++++++--------------
 t/test-lib-functions.sh     |  8 ++++++++
 2 files changed, 31 insertions(+), 14 deletions(-)
-:  ---------- > 1:  5f257af6c8 t7406: fix call that was failing for the wrong reason
1:  3c369bf73d ! 2:  9e5400a1ad t7406: simplify by using diff --name-only instead of diff --raw
    @@ -16,10 +16,10 @@
      	  compare_head
      	 ) &&
     -	 git diff --raw | grep "	submodule" &&
    -+	 git diff --name-only | grep submodule &&
    ++	 git diff --name-only | grep ^submodule$ &&
      	 git submodule update &&
     -	 git diff --raw | grep "	submodule" &&
    -+	 git diff --name-only | grep submodule &&
    ++	 git diff --name-only | grep ^submodule$ &&
      	 (cd submodule &&
      	  compare_head
      	 ) &&
    @@ -28,10 +28,12 @@
      	  compare_head
      	 ) &&
     -	 git diff --raw | grep "	submodule" &&
    -+	 git diff --name-only | grep submodule &&
    ++	 git diff --name-only | grep ^submodule$ &&
      	 git submodule update --checkout &&
    --	 test_must_fail git diff --raw \| grep "	submodule" &&
    -+	 test_must_fail git diff --name-only \| grep submodule &&
    +-	 git diff --raw >out &&
    +-	 ! grep "	submodule" out &&
    ++	 git diff --name-only >out &&
    ++	 ! grep ^submodule$ out &&
      	 (cd submodule &&
      	  test_must_fail compare_head
      	 ) &&
2:  ba50d6b0f3 ! 3:  4e8cdf60f4 t7406: avoid having git commands upstream of a pipe
    @@ -26,13 +26,13 @@
      	  git checkout master &&
      	  compare_head
      	 ) &&
    --	 git diff --name-only | grep submodule &&
    +-	 git diff --name-only | grep ^submodule$ &&
     +	 git diff --name-only >out &&
    -+	 grep submodule out &&
    ++	 grep ^submodule$ out &&
      	 git submodule update &&
    --	 git diff --name-only | grep submodule &&
    +-	 git diff --name-only | grep ^submodule$ &&
     +	 git diff --name-only >out &&
    -+	 grep submodule out &&
    ++	 grep ^submodule$ out &&
      	 (cd submodule &&
      	  compare_head
      	 ) &&
    @@ -40,12 +40,12 @@
      	  git checkout master &&
      	  compare_head
      	 ) &&
    --	 git diff --name-only | grep submodule &&
    +-	 git diff --name-only | grep ^submodule$ &&
     +	 git diff --name-only >out &&
    -+	 grep submodule out &&
    ++	 grep ^submodule$ out &&
      	 git submodule update --checkout &&
    - 	 test_must_fail git diff --name-only \| grep submodule &&
    - 	 (cd submodule &&
    +	 git diff --name-only >out &&
    +	 ! grep ^submodule$ out &&
     @@
      	 H=$(git rev-parse --short HEAD) &&
      	 git commit -am "pre move" &&
3:  42f7b7f225 ! 4:  f171cbcc9a t7406: prefer test_* helper functions to test -[feds]
    @@ -6,13 +6,12 @@
         test failures, so use the test_* helper functions from
         test-lib-functions.sh.
     
    -    Note: The use of 'test_path_is_file submodule/.git' may look odd, but
    -    it is a file which is populated with a
    +    Also, add test_path_exists() to test-lib-function.sh while at it, so
    +    that we don't need to worry whether submodule/.git is a file or a
    +    directory.  It currently is a file with contents of the form
            gitdir: ../.git/modules/submodule
    -    directive.  If, in the future, handling of the submodule is changed and
    -    submodule/.git becomes a directory we can change this to
    -    test_path_is_dir (or perhaps write a test_path_exists helper function
    -    that doesn't care whether the path is a file or a directory).
    +    but it could be changed in the future to be a directory; this test
    +    only really cares that it exists.
     
         Signed-off-by: Elijah Newren <newren@gmail.com>
     
    @@ -34,8 +33,27 @@
      	 git submodule update --init &&
     -	 test -e submodule/.git &&
     -	 test_must_fail test -e none/.git
    -+	 test_path_is_file submodule/.git &&
    ++	 test_path_exists submodule/.git &&
     +	 test_path_is_missing none/.git
      	)
      '
      
    +
    +diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
    +--- a/t/test-lib-functions.sh
    ++++ b/t/test-lib-functions.sh
    +@@
    +	fi
    + }
    +
    ++test_path_exists () {
    ++	if ! test -e "$1"
    ++	then
    ++		echo "Path $1 doesn't exist. $2"
    ++		false
    ++	fi
    ++}
    ++
    + # Check if the directory exists and is empty as expected, barf otherwise.
    + test_dir_is_empty () {
    +	test_path_is_dir "$1" &&
4:  54cf6531ec ! 5:  a44c566321 t7406: avoid using test_must_fail for commands other than git
    @@ -8,8 +8,8 @@
     --- a/t/t7406-submodule-update.sh
     +++ b/t/t7406-submodule-update.sh
     @@
    - 	 git submodule update --checkout &&
    - 	 test_must_fail git diff --name-only \| grep submodule &&
    +	 git diff --name-only >out &&
    +	 ! grep ^submodule$ out &&
      	 (cd submodule &&
     -	  test_must_fail compare_head
     +	  ! compare_head
5:  3019f2d01c < -:  ---------- t7406: fix call that was failing for the wrong reason
-- 
2.18.0.556.g1604670984
Previous: Elijah NewrenNext: Elijah Newren
Message 26 of 33 in “t7406: Make a test_must_fail call fail for the right reason”
  1. t7406: Make a test_must_fail call fail for the right reasonElijah Newren, Aug 3, 2018
  2. Junio C HamanoAug 3, 2018
  3. Eric SunshineAug 3, 2018
  4. Eric SunshineAug 3, 2018
  5. 0/2 Simple fixes to t7406Elijah Newren, Aug 6, 2018
  6. 1/3 t7406: simplify by using diff --name-only instead of diff --rawElijah Newren, Aug 6, 2018
  7. 2/3 t7406: avoid having git commands upstream of a pipeElijah Newren, Aug 6, 2018
  8. SZEDER GáborAug 6, 2018
  9. Elijah NewrenAug 6, 2018
  10. 3/3 t7406: make a test_must_fail call fail for the right reasonElijah Newren, Aug 6, 2018
  11. SZEDER GáborAug 7, 2018
  12. Elijah NewrenAug 7, 2018
  13. Martin ÅgrenAug 7, 2018
  14. Elijah NewrenAug 7, 2018
  15. 0/5 Simple fixes to t7406Elijah Newren, Aug 7, 2018
  16. 1/5 t7406: simplify by using diff --name-only instead of diff --rawElijah Newren, Aug 7, 2018
  17. Junio C HamanoAug 7, 2018
  18. Elijah NewrenAug 7, 2018
  19. Junio C HamanoAug 7, 2018
  20. 3/5 t7406: prefer test_* helper functions to test -[feds]Elijah Newren, Aug 7, 2018
  21. Junio C HamanoAug 7, 2018
  22. 5/5 t7406: fix call that was failing for the wrong reasonElijah Newren, Aug 7, 2018
  23. Junio C HamanoAug 7, 2018
  24. 4/5 t7406: avoid using test_must_fail for commands other than gitElijah Newren, Aug 7, 2018
  25. 2/5 t7406: avoid having git commands upstream of a pipeElijah Newren, Aug 7, 2018
  26. 0/5 Simple fixes to t7406Elijah Newren, Aug 8, 2018
  27. 5/5 t7406: avoid using test_must_fail for commands other than gitElijah Newren, Aug 8, 2018
  28. 2/5 t7406: simplify by using diff --name-only instead of diff --rawElijah Newren, Aug 8, 2018
  29. 4/5 t7406: prefer test_* helper functions to test -[feds]Elijah Newren, Aug 8, 2018
  30. 1/5 t7406: fix call that was failing for the wrong reasonElijah Newren, Aug 8, 2018
  31. 3/5 t7406: avoid having git commands upstream of a pipeElijah Newren, Aug 8, 2018
  32. SZEDER GáborAug 13, 2018
  33. Elijah NewrenAug 18, 2018

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.