diff mbox series

[1/4] t7800-difftool: cleanup temporary repositories used by tests

Message ID 20210919015729.98323-1-davvid@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/4] t7800-difftool: cleanup temporary repositories used by tests | expand

Commit Message

David Aguilar Sept. 19, 2021, 1:57 a.m. UTC
The "dirlinks" and "growing" repositories should not outlive the
tests that use them.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 t/t7800-difftool.sh | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ævar Arnfjörð Bjarmason Sept. 19, 2021, 1:25 p.m. UTC | #1
On Sat, Sep 18 2021, David Aguilar wrote:

> The "dirlinks" and "growing" repositories should not outlive the
> tests that use them.

Why not? The pattern of not bothering to clean up the work scratch are
is fine as long as it doesn't leave crap around for other tests. See the
referenec to "repo" at[1].

I.e. is this needed for later tests that change in this series, or just
cleanup in case a future test ever cares that there's an untracked
"dirlinks" and "growing" directory at the top-level?

1. https://lore.kernel.org/git/87y27veeyj.fsf@evledraar.gmail.com/
Junio C Hamano Sept. 20, 2021, 6:28 p.m. UTC | #2
David Aguilar <davvid@gmail.com> writes:

> The "dirlinks" and "growing" repositories should not outlive the
> tests that use them.
>
> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
>  t/t7800-difftool.sh | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index a173f564bc..a923f193da 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -414,6 +414,7 @@ test_expect_success 'setup change in subdirectory' '
>  test_expect_success 'difftool -d with growing paths' '
>  	a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
>  	git init growing &&
> +	test_when_finished rm -rf growing &&

If "git init" fails after it created the directory, it will be left
behind because test_when_finished hasn't been called yet.  The same
problem exists in the other hunk.  Moving it above "git init" may
trigger "rm -rf X" where X does not exist yet, but that is what you
are giving the 'f'orce option there for.

Not a huge deal and no need to resend only to fix them alone,
though.

>  	(
>  		cd growing &&
>  		echo "test -f \"\$2/b\"" | write_script .git/test-for-b.sh &&
> @@ -646,6 +647,7 @@ test_expect_success 'difftool properly honors gitlink and core.worktree' '
>  test_expect_success SYMLINKS 'difftool --dir-diff symlinked directories' '
>  	test_when_finished git reset --hard &&
>  	git init dirlinks &&
> +	test_when_finished rm -rf dirlinks &&
>  	(
>  		cd dirlinks &&
>  		git config diff.tool checktrees &&
diff mbox series

Patch

diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index a173f564bc..a923f193da 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -414,6 +414,7 @@  test_expect_success 'setup change in subdirectory' '
 test_expect_success 'difftool -d with growing paths' '
 	a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
 	git init growing &&
+	test_when_finished rm -rf growing &&
 	(
 		cd growing &&
 		echo "test -f \"\$2/b\"" | write_script .git/test-for-b.sh &&
@@ -646,6 +647,7 @@  test_expect_success 'difftool properly honors gitlink and core.worktree' '
 test_expect_success SYMLINKS 'difftool --dir-diff symlinked directories' '
 	test_when_finished git reset --hard &&
 	git init dirlinks &&
+	test_when_finished rm -rf dirlinks &&
 	(
 		cd dirlinks &&
 		git config diff.tool checktrees &&