Jens Lehmann <Jens.Lehmann@xxxxxx> writes: > Fixed all places where it was a straightforward change from cd'ing into a > directory and back via "cd .." to a cd inside a subshell. > > Found these places with "git grep -w "cd \.\.". > > Signed-off-by: Jens Lehmann <Jens.Lehmann@xxxxxx> > --- Thanks; that is a huge effort of cleaning things up. > diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh > index 5687499..c36157a 100755 > --- a/t/t1020-subdirectory.sh > +++ b/t/t1020-subdirectory.sh > @@ -27,13 +27,13 @@ test_expect_success 'update-index and ls-files' ' > one) echo pass one ;; > *) echo bad one; exit 1 ;; > esac && > - cd dir && > + (cd dir && > git update-index --add two && > case "`git ls-files`" in > two) echo pass two ;; > *) echo bad two; exit 1 ;; > - esac && > - cd .. && > + esac > + ) && > case "`git ls-files`" in > dir/two"$LF"one) echo pass both ;; > *) echo bad; exit 1 ;; If we were to do this, shouldn't we be able to lose 'cd "$HERE"' at the beginning of each test? The test after this one does "cd dir" without even coming back up and relies on the next one to go back itself, suggesting that grepping for 'cd ..' may not be sufficient, depending on what we are trying to fix. If we were to insist that no matter how an individual test fail, the test that follows it must start in a known location (namely, $TRASH), then we might want to use something like the attached patch. On the other hand, we might want to be lenient to a test suite whose one test moves around and the test that follows such a test knows that, and also anticipates that the previous one _can_ fail and tries recover from that failure (e.g. use of 'cd "$HERE"' in the test that follows the above one. Thoughts? t/test-lib.sh | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 29fd720..f07f275 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -432,10 +432,14 @@ test_expect_success () { error "bug in the test script: not 2 or 3 parameters to test-expect-success" if ! test_skip "$@" then + test ",$TRASH_DIRECTORY" = ",$(pwd)" || + error "bug in the test script: starting from a different directory" say >&3 "expecting success: $2" test_run_ "$2" if [ "$?" = 0 -a "$eval_ret" = 0 ] then + test ",$TRASH_DIRECTORY" = ",$(pwd)" || + error "bug in the test script: moved to a different directory" test_ok_ "$1" else test_failure_ "$@" -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html