Re: [PATCH] t2028: fix minor error and issues in newly-added "worktree move" tests
From: SZEDER Gábor <hidden>
Date: 2018-03-05 12:49:17
Recently-added "git worktree move" tests include a minor error and a few
small issues. Specifically:
* checking non-existence of wrong file ("source" instead of
"destination")
* unneeded redirect (">empty")
* unused variable ("toplevel")
* restoring a worktree location by means of a separate test somewhat
distant from the test which moved it rather than using
test_when_finished() to restore it in a self-contained fashionThere is one more issue in these tests.
quoted hunk ↗ jump to hunk
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh index 082368d8c6..d70d13dabe 100755 --- a/t/t2028-worktree-move.sh +++ b/t/t2028-worktree-move.sh@@ -75,7 +75,7 @@ test_expect_success 'move worktree' ' git worktree move source destination && test_path_is_missing source && git worktree list --porcelain | grep "^worktree.*/destination" && - ! git worktree list --porcelain | grep "^worktree.*/source" >empty && + ! git worktree list --porcelain | grep "^worktree.*/source" &&
The main purpose of this test script is to test the 'git worktree' command, but these pipes hide its exit code. Could you please save 'git worktree's output into an intermediate file, and run 'grep' on the file's contents? This also applies to two other tests in this test script.
quoted hunk ↗ jump to hunk
git -C destination log --format=%s >actual2 && echo init >expected2 && test_cmp expected2 actual2@@ -86,10 +86,10 @@ test_expect_success 'move main worktree' ' ' test_expect_success 'move worktree to another dir' ' - toplevel="$(pwd)" && mkdir some-dir && git worktree move destination some-dir && - test_path_is_missing source && + test_when_finished "git worktree move some-dir/destination destination" && + test_path_is_missing destination && git worktree list --porcelain | grep "^worktree.*/some-dir/destination" && git -C some-dir/destination log --format=%s >actual2 && echo init >expected2 &&@@ -100,10 +100,6 @@ test_expect_success 'remove main worktree' ' test_must_fail git worktree remove . ' -test_expect_success 'move some-dir/destination back' ' - git worktree move some-dir/destination destination -' - test_expect_success 'remove locked worktree' ' git worktree lock destination && test_when_finished "git worktree unlock destination" &&-- 2.16.2.660.g709887971b