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

[PATCH] Test: catch if trash cannot be removed

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2008, 04:58 UTC
Message-ID
<7vd4pr5mzq.fsf@gitster.siamese.dyndns.org>

When your test creates an unwritable directory that test framework cannot clean out by "rm -fr trash", later tests cannot start in a fresh state they expect to. Detect this and error out early.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/test-lib.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 268b26c..870b255 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -396,7 +396,12 @@ fi
 
 # Test repository
 test=trash
-rm -fr "$test"
+rm -fr "$test" || {
+	trap - exit
+	echo >&5 "FATAL: Cannot prepare test area"
+	exit 1
+}
+
 test_create_repo $test
 cd "$test"
 
-- 
1.5.5.rc0.122.g8e28f
Message 1 of 1 in “Test: catch if trash cannot be removed”
  1. Test: catch if trash cannot be removedJunio C Hamano, Mar 19, 2008

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.