From: Sverre Rabbelier Date: Mon, 09 Jun 2008 00:44:01 GMT Subject: [PATCH 4/4] Make test-lib warn if the directory changes. Message-ID: <1212972241-7348-1-git-send-email-srabbelier@gmail.com> In-Reply-To: <7vej77iqxb.fsf@gitster.siamese.dyndns.org> From: Sverre Rabbelier 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 --- 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