Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Print runtime for integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwinter committed Mar 2, 2022
1 parent 6d74bca commit 7638cac
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions metafix/integrationTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ function run_catmandu() {
:
}

nanosecond_offset=-9

function current_time() {
date +%s%N
}

function elapsed_time() {
local elapsed_time=$(($(current_time) - $1))

local seconds=${elapsed_time:0:$nanosecond_offset} milliseconds
[ "$seconds" -lt 60 ] && milliseconds=".${elapsed_time:$nanosecond_offset:3}"

echo " ($(date "+%-Hh %-Mm %-S${milliseconds}s" -ud "@$seconds" | sed 's/^\(0[hm] \)*//'))"
}

function get_file() {
local test=$1 type=$2 reason; shift 2

Expand Down Expand Up @@ -127,6 +142,8 @@ function run_tests() {
metafix_command_output="$test_directory/metafix.out"
metafix_command_error="$test_directory/metafix.err"

metafix_start_time=$(current_time)

# TODO: catmandu (optional)

if run_metafix "$test_directory/$metafix_file" >"$metafix_command_output" 2>"$metafix_command_error"; then
Expand All @@ -136,16 +153,18 @@ function run_tests() {
metafix_output=$current_file
metafix_diff="$test_directory/metafix.diff"

metafix_elapsed_time=$(elapsed_time "$metafix_start_time")

if diff -u "$test_expected" "$metafix_output" >"$metafix_diff"; then
#log "$color_test$test$color_reset: ${color_passed}PASSED$color_reset"
#log "$color_test$test$color_reset: ${color_passed}PASSED$color_reset$metafix_elapsed_time"

rm -f "$metafix_diff" "$metafix_command_output" "$metafix_command_error"

((passed++)) || true

#log
else
log "$color_test$test$color_reset: ${color_failed}FAILED$color_reset"
log "$color_test$test$color_reset: ${color_failed}FAILED$color_reset$metafix_elapsed_time"

log " Fix: $test_fix"
log " Input: $test_input"
Expand Down Expand Up @@ -185,6 +204,8 @@ function run_tests() {
return $matched
}

start_time=$(current_time)

if [ $# -eq 0 ]; then
run_tests '*' || true
else
Expand All @@ -199,6 +220,7 @@ summary="${color_passed}$passed passed$color_reset"
summary+=", ${color_failed}$failed failed$color_reset"
summary+=", ${color_skipped}$skipped skipped$color_reset"
summary+=", ${color_invalid}$invalid invalid$color_reset"
summary+=$(elapsed_time "$start_time")

if [ $failed -gt 0 -o $invalid -gt 0 ]; then
log "${color_failure}FAILURE$color_reset: $summary"
Expand Down

0 comments on commit 7638cac

Please sign in to comment.