]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/test-lib.sh
pretty: add "%aL" etc. to show local-part of email addresses
[thirdparty/git.git] / t / test-lib.sh
index ee602c4d9cd79f08a3cfcbafaf81051937f57f0b..46c44408432ed93dbb2126def0fa05b4159e0548 100644 (file)
@@ -404,9 +404,13 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
 unset XDG_CACHE_HOME
 unset XDG_CONFIG_HOME
 unset GITPERLLIB
-GIT_AUTHOR_EMAIL=author@example.com
+TEST_AUTHOR_LOCALNAME=author
+TEST_AUTHOR_DOMAIN=example.com
+GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN}
 GIT_AUTHOR_NAME='A U Thor'
-GIT_COMMITTER_EMAIL=committer@example.com
+TEST_COMMITTER_LOCALNAME=committer
+TEST_COMMITTER_DOMAIN=example.com
+GIT_COMMITTER_EMAIL=${TEST_COMMITTER_LOCALNAME}@${TEST_COMMITTER_DOMAIN}
 GIT_COMMITTER_NAME='C O Mitter'
 GIT_MERGE_VERBOSITY=5
 GIT_MERGE_AUTOEDIT=no
@@ -572,6 +576,7 @@ export TERM
 
 error () {
        say_color error "error: $*"
+       finalize_junit_xml
        GIT_EXIT_OK=t
        exit 1
 }
@@ -700,7 +705,7 @@ test_failure_ () {
        say_color error "not ok $test_count - $1"
        shift
        printf '%s\n' "$*" | sed -e 's/^/#      /'
-       test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
+       test "$immediate" = "" || { finalize_junit_xml; GIT_EXIT_OK=t; exit 1; }
 }
 
 test_known_broken_ok_ () {
@@ -1068,6 +1073,25 @@ write_junit_xml_testcase () {
        junit_have_testcase=t
 }
 
+finalize_junit_xml () {
+       if test -n "$write_junit_xml" && test -n "$junit_xml_path"
+       then
+               test -n "$junit_have_testcase" || {
+                       junit_start=$(test-tool date getnanos)
+                       write_junit_xml_testcase "all tests skipped"
+               }
+
+               # adjust the overall time
+               junit_time=$(test-tool date getnanos $junit_suite_start)
+               sed "s/<testsuite [^>]*/& time=\"$junit_time\"/" \
+                       <"$junit_xml_path" >"$junit_xml_path.new"
+               mv "$junit_xml_path.new" "$junit_xml_path"
+
+               write_junit_xml "  </testsuite>" "</testsuites>"
+               write_junit_xml=
+       fi
+}
+
 test_atexit_cleanup=:
 test_atexit_handler () {
        # In a succeeding test script 'test_atexit_handler' is invoked
@@ -1090,21 +1114,7 @@ test_done () {
        # removed, so the commands can access pidfiles and socket files.
        test_atexit_handler
 
-       if test -n "$write_junit_xml" && test -n "$junit_xml_path"
-       then
-               test -n "$junit_have_testcase" || {
-                       junit_start=$(test-tool date getnanos)
-                       write_junit_xml_testcase "all tests skipped"
-               }
-
-               # adjust the overall time
-               junit_time=$(test-tool date getnanos $junit_suite_start)
-               sed "s/<testsuite [^>]*/& time=\"$junit_time\"/" \
-                       <"$junit_xml_path" >"$junit_xml_path.new"
-               mv "$junit_xml_path.new" "$junit_xml_path"
-
-               write_junit_xml "  </testsuite>" "</testsuites>"
-       fi
+       finalize_junit_xml
 
        if test -z "$HARNESS_ACTIVE"
        then