git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t9123: use test_when_finished for cleanup

From
Siddharth Shrimali <r.siddharth.shrimali@gmail.com>
Date
Mar 5, 2026, 12:54 UTC
Message-ID
<20260305125408.16958-1-r.siddharth.shrimali@gmail.com>

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(-)
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
Message 1 of 1 in “t9123: use test_when_finished for cleanup”
  1. t9123: use test_when_finished for cleanupSiddharth Shrimali, Mar 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.