Thread (24 messages) flat view 24 messages, 3 authors, 2016-06-15

Re: [PATCHv4 04/15] t4002 (diff-basic): use test_might_fail for commands that might fail

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:49:40
Subsystem: the rest · Maintainer: Linus Torvalds

Elijah Newren wrote:
quoted hunk ↗ jump to hunk
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -205,8 +205,8 @@ test_expect_success \
     'rm -fr Z [A-Z][A-Z] &&
      git read-tree $tree_A &&
      git checkout-index -f -a &&
-     git read-tree --reset $tree_O || return 1
-     git update-index --refresh >/dev/null ;# this can exit non-zero
+     git read-tree --reset $tree_O &&
+     test_might_fail git update-index --refresh >/dev/null &&
      git diff-files >.test-a &&
Makes sense; thanks.  But aren't we actually guaranteed that it will
fail, since the index does not match the work tree?

Meanwhile, what was the point of refreshing the index like this?
I would guess it was to make sure that files that match the work tree
are marked as matching, but if so, this is not guaranteed if
update-index --refresh exits early.  Adding -q would fix that.

Why redirect to /dev/null?  I would think the extra output would
be useful while debugging with -v.
---
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 340aa7d..9fb8ca0 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -206,7 +206,7 @@ test_expect_success \
      git read-tree $tree_A &&
      git checkout-index -f -a &&
      git read-tree --reset $tree_O &&
-     test_might_fail git update-index --refresh >/dev/null &&
+     test_must_fail git update-index --refresh -q &&
      git diff-files >.test-a &&
      cmp_diff_files_output .test-a .test-recursive-OA'
 
@@ -216,7 +216,7 @@ test_expect_success \
      git read-tree $tree_B &&
      git checkout-index -f -a &&
      git read-tree --reset $tree_O &&
-     test_might_fail git update-index --refresh >/dev/null &&
+     test_must_fail git update-index --refresh -q &&
      git diff-files >.test-a &&
      cmp_diff_files_output .test-a .test-recursive-OB'
 
@@ -226,7 +226,7 @@ test_expect_success \
      git read-tree $tree_B &&
      git checkout-index -f -a &&
      git read-tree --reset $tree_A &&
-     test_might_fail git update-index --refresh >/dev/null &&
+     test_must_fail git update-index --refresh -q &&
      git diff-files >.test-a &&
      cmp_diff_files_output .test-a .test-recursive-AB'
 
-- 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help