{"thread":{"id":"65140","subject":"[PATCH] t9123: use test_when_finished for cleanup","startedAt":"2026-03-05T12:54:20Z","lastAt":"2026-03-05T12:54:20Z","messageCount":1,"participants":["Siddharth Shrimali"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"537932","messageId":"20260305125408.16958-1-r.siddharth.shrimali@gmail.com","threadId":"65140","inReplyTo":null,"subject":"[PATCH] t9123: use test_when_finished for cleanup","fromName":"Siddharth Shrimali","fromEmail":"r.siddharth.shrimali@gmail.com","sentAt":"2026-03-05T12:54:08Z","receivedAt":"2026-03-05T12:54:20Z","isPatch":true,"sender":{"key":"r.siddharth.shrimali@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183274193?v=4"},"body":"Move the setup logic into a 'test_expect_success' block.\nThis ensures that the code is properly tracked by the test harness.\n\nAdditionally, we use the 'test_when_finished' helper at the start of\nthe block to ensure that the 'import' directory is removed even if the\ntest fails.\nThis is cleaner than the previous manual 'rm -rf import' approach.\n\nSigned-off-by: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>\n---\nI have kept the SVN setup and the Git SVN initialization in separate\nblocks for clarity. Would you prefer these to be combined into a \nsingle setup block?\n\n t/t9123-git-svn-rebuild-with-rewriteroot.sh | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh\nindex ead404589e..8fa5940abe 100755\n--- a/t/t9123-git-svn-rebuild-with-rewriteroot.sh\n+++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh\n@@ -7,12 +7,15 @@ test_description='git svn respects rewriteRoot during rebuild'\n \n . ./lib-git-svn.sh\n \n-mkdir import\n-(cd import\n-\ttouch foo\n-\tsvn_cmd import -m 'import for git svn' . \"$svnrepo\" >/dev/null\n-)\n-rm -rf import\n+test_expect_success 'setup svn repository' '\n+\ttest_when_finished \"rm -rf import\" &&\n+\tmkdir import &&\n+\t(\n+\t\tcd import &&\n+\t\ttouch foo &&\n+\t\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" >/dev/null\n+\t)\n+\t'\n \n test_expect_success 'init, fetch and checkout repository' '\n \tgit svn init --rewrite-root=http://invalid.invalid/ \"$svnrepo\" &&\n-- \n2.51.2\n\n"}]}