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

[PATCH 4/4] Make test-lib warn if the directory changes.

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Jun 9, 2008, 00:44 UTC
Message-ID
<1212972241-7348-1-git-send-email-srabbelier@gmail.com>
In-Reply-To
<7vej77iqxb.fsf@gitster.siamese.dyndns.org>
From: Sverre Rabbelier <srabbelier@gmail.com>

If a script moves out of it's directory, but thereafter does not move back, the test results would not get written to the proper file, as such, remember where we start at and then later on, write to that place. Also, if it is noticed that the directory was changed, issue a warning.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
 t/test-lib.sh |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 4585fde..d9f2f4e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -5,6 +5,7 @@
 
 # Keep the original TERM for say_color
 ORIGINAL_TERM=$TERM
+ORIGINAL_PATH=$PWD
 
 # For repeatability, reset the environment to known value.
 LANG=C
@@ -355,7 +356,12 @@ test_create_repo () {
 
 test_done () {
 	trap - exit
-	test_results_path="../test-results"
+	test_results_path="$ORIGINAL_PATH/test-results"
+
+  if test "$ORIGINAL_PATH" != "$PWD"
+  then
+    say_color error "Script changed directory from '$ORIGINAL_PATH' to '$PWD'!"
+  fi
 
 	echo "total $test_count" >> $test_results_path
 	echo "success $test_success" >> $test_results_path
-- 
1.5.6.rc2
Previous: Junio C Hamano
Message 9 of 9 in “Modified test-lib.sh to output stats to /tmp/git-test-results”
  1. 1/3 Modified test-lib.sh to output stats to /tmp/git-test-resultsSverre Rabbelier, Jun 8, 2008
  2. 2/3 A simple script to parse the results from the testcasesSverre Rabbelier, Jun 8, 2008
  3. 3/3 Hook up the result aggregation in the test makefile.Sverre Rabbelier, Jun 8, 2008
  4. Jakub NarebskiJun 8, 2008
  5. Sverre RabbelierJun 8, 2008
  6. Junio C HamanoJun 8, 2008
  7. Sverre RabbelierJun 8, 2008
  8. Junio C HamanoJun 8, 2008
  9. 4/4 Make test-lib warn if the directory changes.Sverre Rabbelier, Jun 9, 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.