diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-18 14:19:41 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-08-18 14:19:41 -0400 |
commit | e06e7bbf5967f7908445d067a767f1908725d641 (patch) | |
tree | 195e2ca75734a4d7b6784da672c6efe21038a814 /integration2tap | |
parent | d1ae89aaf9539f044a2152d79a5719d7c21561f8 (diff) |
convert integration test log to TAP
Diffstat (limited to 'integration2tap')
-rwxr-xr-x | integration2tap | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/integration2tap b/integration2tap new file mode 100755 index 0000000..bea8123 --- /dev/null +++ b/integration2tap @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +# 2018 Luke Shumaker + +test='' +output='' +is_tap=maybe +while read -r line; do + if [[ $line = '--x-- '*' --x--' ]]; then + is_tap=false + msg=${line#'--x-- '} + msg=${msg%' --x--'} + case "$msg" in + 'Running '*) + test=${msg#'Running '} + output="$line"$'\n' + ;; + 'Result of '*) + output+="$line"$'\n' + result=${msg##*:} + n=${test#TEST-} + n=${n%%-*} + if (( result == 0 )); then + printf 'ok %d %s\n' "${n#0}" "$test" + else + printf 'not ok %d %s\n' "${n#0}" "$test" + fi + printf '%s' "$output" | sed 's/^/# /' + test='' + output='' + ;; + esac + else + if [[ $is_tap = maybe && ( $line = TAP* || $line = 1..* ) ]]; then + # Maybe I'll convince upstream to emit TAP... + printf '%s\n' "$line" + sed '$d' + exit 0 + fi + if [[ -n $test ]]; then + output+="$line"$'\n' + else + case "$line" in + 'ALL '*' TESTS PASSED') + m=${line#'ALL '} + m=${m%%' '*} + printf '1..%d\n' "${m#0}" + exit 0 + :;; + 'TOTAL FAILURES: '*' OF '*) + m=${line##*' '} + printf '1..%d\n' "${m#0}" + exit 0 + :;; + *) + : # discard + ;; + esac + fi + fi +done < <(sed 's/\r$//' | cat -v) +echo 'Bail out!' |