From d57d5b25c19b59375fd053e8dbbe4f8ec2fd2a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 21 Apr 2018 18:58:46 +0200 Subject: [PATCH] ci: Collect test times for sharness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- .../0001-Generate-partial-JUnit-reports.patch | 43 +++++++++++-------- test/sharness/lib/install-sharness.sh | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/test/sharness/lib/0001-Generate-partial-JUnit-reports.patch b/test/sharness/lib/0001-Generate-partial-JUnit-reports.patch index 32500da65a79..35e9a5b44558 100644 --- a/test/sharness/lib/0001-Generate-partial-JUnit-reports.patch +++ b/test/sharness/lib/0001-Generate-partial-JUnit-reports.patch @@ -1,14 +1,14 @@ -From 76b34f25b2bacdd30138b25ccbe0672d76a1632a Mon Sep 17 00:00:00 2001 +From 57babdc669bb6b730f590865bcc39d9cb834f294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= -Date: Thu, 22 Mar 2018 06:11:01 +0100 +Date: Sat, 21 Apr 2018 19:26:10 +0200 Subject: [PATCH] Generate partial JUnit reports --- - sharness.sh | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- - 1 file changed, 96 insertions(+), 6 deletions(-) + sharness.sh | 109 +++++++++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 103 insertions(+), 6 deletions(-) diff --git a/sharness.sh b/sharness.sh -index 6750ff7..7d9915a 100644 +index 6750ff7..cfae17a 100644 --- a/sharness.sh +++ b/sharness.sh @@ -1,4 +1,4 @@ @@ -52,7 +52,7 @@ index 6750ff7..7d9915a 100644 test -n "$test_description" || error "Test script did not set test_description." if test "$help" = "t"; then -@@ -251,30 +265,75 @@ test_have_prereq() { +@@ -251,30 +265,76 @@ test_have_prereq() { test $total_prereq = $ok_prereq } @@ -65,10 +65,11 @@ index 6750ff7..7d9915a 100644 + + test_name=$1 + tc_file=".junit/case-$(printf "%04d" $test_count)" ++ time_sec="$(cat .junit/time | sed -e 's/\(...\)$/.\1/g')" + + shift + cat > "$tc_file" <<-EOF -+ ++ + $@ + EOF + @@ -89,7 +90,7 @@ index 6750ff7..7d9915a 100644 + fi + + echo "" >> "$tc_file" -+ rm -f .junit/tout .junit/terr ++ rm -f .junit/tout .junit/terr .junit/time +} + # You are not expected to call test_ok_ and test_failure_ directly, use @@ -128,20 +129,26 @@ index 6750ff7..7d9915a 100644 } # Public: Execute commands in debug mode. -@@ -310,7 +369,11 @@ test_pause() { +@@ -310,7 +370,17 @@ test_pause() { test_eval_() { # This is a separate function because some tests use # "return" to end a test_expect_success block early. - eval &3 2>&4 "$*" + if test -n "$TEST_GENERATE_JUNIT"; then ++ date "+%s%3N" > .junit/start ++ + eval >(tee -a .junit/tout >&3) 2> >(tee -a .junit/terr >&4) "$*" ++ status=$? ++ ++ echo $(expr $(date "+%s%3N") - $(cat ".junit/start") ) > .junit/time ++ return ${status} + else + eval &3 2>&4 "$*" + fi } test_run_() { -@@ -355,8 +418,18 @@ test_skip_() { +@@ -355,8 +425,18 @@ test_skip_() { of_prereq=" of $test_prereq" fi @@ -152,7 +159,7 @@ index 6750ff7..7d9915a 100644 + + if test -n "$TEST_GENERATE_JUNIT"; then + cat > ".junit/case-$(printf "%04d" $test_count)" <<-EOF -+ ++ + + skip $(echo $1 | esc_xml) (missing $missing_prereq${of_prereq}) + @@ -162,7 +169,7 @@ index 6750ff7..7d9915a 100644 : true ;; *) -@@ -403,7 +476,7 @@ test_expect_success() { +@@ -403,7 +483,7 @@ test_expect_success() { test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_success" export test_prereq @@ -171,7 +178,7 @@ index 6750ff7..7d9915a 100644 say >&3 "expecting success: $2" if test_run_ "$2"; then test_ok_ "$1" -@@ -442,7 +515,7 @@ test_expect_failure() { +@@ -442,7 +522,7 @@ test_expect_failure() { test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_failure" export test_prereq @@ -180,7 +187,7 @@ index 6750ff7..7d9915a 100644 say >&3 "checking known breakage: $2" if test_run_ "$2" expecting_failure; then test_known_broken_ok_ "$1" -@@ -675,6 +748,7 @@ test_done() { +@@ -675,6 +755,7 @@ test_done() { test_results_dir="$SHARNESS_TEST_DIRECTORY/test-results" mkdir -p "$test_results_dir" test_results_path="$test_results_dir/${SHARNESS_TEST_FILE%.$SHARNESS_TEST_EXTENSION}.$$.counts" @@ -188,7 +195,7 @@ index 6750ff7..7d9915a 100644 cat >>"$test_results_path" <<-EOF total $test_count -@@ -684,6 +758,14 @@ test_done() { +@@ -684,6 +765,14 @@ test_done() { failed $test_failure EOF @@ -203,7 +210,7 @@ index 6750ff7..7d9915a 100644 fi if test "$test_fixed" != 0; then -@@ -745,6 +827,9 @@ export PATH SHARNESS_BUILD_DIRECTORY +@@ -745,6 +834,9 @@ export PATH SHARNESS_BUILD_DIRECTORY SHARNESS_TEST_FILE="$0" export SHARNESS_TEST_FILE @@ -213,7 +220,7 @@ index 6750ff7..7d9915a 100644 # Prepare test area. test_dir="trash directory.$(basename "$SHARNESS_TEST_FILE" ".$SHARNESS_TEST_EXTENSION")" test -n "$root" && test_dir="$root/$test_dir" -@@ -771,6 +856,11 @@ mkdir -p "$test_dir" || exit 1 +@@ -771,6 +863,11 @@ mkdir -p "$test_dir" || exit 1 # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$test_dir" || exit 1 @@ -226,5 +233,5 @@ index 6750ff7..7d9915a 100644 this_test=${this_test%.$SHARNESS_TEST_EXTENSION} for skp in $SKIP_TESTS; do -- -2.16.2 +2.17.0 diff --git a/test/sharness/lib/install-sharness.sh b/test/sharness/lib/install-sharness.sh index 9a8c3fc746a8..a3001a1529b0 100755 --- a/test/sharness/lib/install-sharness.sh +++ b/test/sharness/lib/install-sharness.sh @@ -7,7 +7,7 @@ # settings version=5eee9b51b5621cec95a64018f0cc779963b230d2 -patch_version=8 +patch_version=10 urlprefix=https://github.com/mlafeldt/sharness.git if test ! -n "$clonedir" ; then