threads / patch / 65140

patcht9123: use test_when_finished for cleanup

Subject: [PATCH] t9123: use test_when_finished for cleanup

## tl;dr

One message between Mar 5, 2026 and Mar 5, 2026. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Siddharth Shrimali· Mar 5, 2026, 12:54 UTC · lore

Move the setup logic into a 'test_expect_success' block. This ensures that the code is properly tracked by the test harness.

Additionally, we use the 'test_when_finished' helper at the start of the block to ensure that the 'import' directory is removed even if the test fails. This is cleaner than the previous manual 'rm -rf import' approach.

Signed-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
---
I have kept the SVN setup and the Git SVN initialization in separate
blocks for clarity. Would you prefer these to be combined into a 
single setup block?
 t/t9123-git-svn-rebuild-with-rewriteroot.sh | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
Show changes to t/t9123-git-svn-rebuild-with-rewriteroot.sh +9 −6
diff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh
index ead404589e..8fa5940abe 100755
--- a/t/t9123-git-svn-rebuild-with-rewriteroot.sh
+++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh
@@ -7,12 +7,15 @@ test_description='git svn respects rewriteRoot during rebuild'
 
 . ./lib-git-svn.sh
 
-mkdir import
-(cd import
-	touch foo
-	svn_cmd import -m 'import for git svn' . "$svnrepo" >/dev/null
-)
-rm -rf import
+test_expect_success 'setup svn repository' '
+	test_when_finished "rm -rf import" &&
+	mkdir import &&
+	(
+		cd import &&
+		touch foo &&
+		svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null
+	)
+	'
 
 test_expect_success 'init, fetch and checkout repository' '
 	git svn init --rewrite-root=http://invalid.invalid/ "$svnrepo" &&
-- 
2.51.2

← back to recent threads