Skip to content

Commit 86a2058

Browse files
authored
Build: Tests: Cleanup aggregate-results and make "make test" fail
Merge pull request #442 from inkarkat/master
2 parents f00ee90 + 8cc2367 commit 86a2058

File tree

2 files changed

+10
-68
lines changed

2 files changed

+10
-68
lines changed

tests/aggregate-results.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ if test -n "$color"; then
1818
say_color() {
1919
(
2020
export TERM
21-
case "$1" in
21+
case "${1:?}" in
2222
error) tput bold; tput setaf 1;; # bold red
2323
skip) tput bold; tput setaf 2;; # bold green
2424
pass) tput setaf 2;; # green
2525
info) tput setaf 3;; # brown
26-
*) test -n "$quiet" && return;;
2726
esac
2827
shift
2928
printf "* %s" "$*"
@@ -33,7 +32,6 @@ if test -n "$color"; then
3332
}
3433
else
3534
say_color() {
36-
test -z "$1" && test -n "$quiet" && return
3735
shift
3836
echo "* $*"
3937
}
@@ -44,7 +42,7 @@ get_color()
4442
# Only use the supplied color if there are actually instances of that
4543
# type, so that a clean test run does not distract the user by the
4644
# appearance of the error highlighting.
47-
if [ ${1:?} -eq 0 ]
45+
if [ "${1:?}" -eq 0 ]
4846
then
4947
echo 'info'
5048
else
@@ -61,21 +59,21 @@ total=0
6159

6260
for file
6361
do
64-
while read type value
62+
while read -r type value
6563
do
6664
case $type in
6765
'')
6866
continue ;;
6967
fixed)
70-
fixed=$((fixed + $value)) ;;
68+
fixed=$((fixed + value)) ;;
7169
success)
72-
success=$((success + $value)) ;;
70+
success=$((success + value)) ;;
7371
failed)
74-
failed=$((failed + $value)) ;;
72+
failed=$((failed + value)) ;;
7573
broken)
76-
broken=$((broken + $value)) ;;
74+
broken=$((broken + value)) ;;
7775
total)
78-
total=$((total + $value)) ;;
76+
total=$((total + value)) ;;
7977
esac
8078
done <"$file"
8179
done
@@ -85,3 +83,5 @@ say_color "$(get_color "$success" 'pass')" "$(printf "%-8s%d\n" success $success
8583
say_color "$(get_color "$failed" 'error')" "$(printf "%-8s%d\n" failed $failed)"
8684
say_color "$(get_color "$broken" 'error')" "$(printf "%-8s%d\n" broken $broken)"
8785
say_color 'info' "$(printf "%-8s%d\n" total $total)"
86+
87+
[ $broken -eq 0 ] && [ $failed -eq 0 ]

tests/test-lib.sh

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -316,64 +316,6 @@ expected exit code $1, actual ${eval_ret}"
316316
echo >&3 ""
317317
}
318318

319-
# test_external runs external test scripts that provide continuous
320-
# test output about their progress, and succeeds/fails on
321-
# zero/non-zero exit code. It outputs the test output on stdout even
322-
# in non-verbose mode, and announces the external script with "* run
323-
# <n>: ..." before running it. When providing relative paths, keep in
324-
# mind that all scripts run in "trash directory".
325-
# Usage: test_external description command arguments...
326-
# Example: test_external 'Perl API' perl ../path/to/test.pl
327-
test_external () {
328-
test "$#" -eq 3 ||
329-
error >&5 "bug in the test script: not 3 parameters to test_external"
330-
descr="$1"
331-
shift
332-
if ! test_skip "$descr" "$@"
333-
then
334-
# Announce the script to reduce confusion about the
335-
# test output that follows.
336-
say_color "" " run $test_count: $descr ($*)"
337-
# Run command; redirect its stderr to &4 as in
338-
# test_run_, but keep its stdout on our stdout even in
339-
# non-verbose mode.
340-
"$@" 2>&4
341-
if [ "$?" = 0 ]
342-
then
343-
test_ok_ "$descr"
344-
else
345-
test_failure_ "$descr" "$@"
346-
fi
347-
fi
348-
}
349-
350-
# Like test_external, but in addition tests that the command generated
351-
# no output on stderr.
352-
test_external_without_stderr () {
353-
# The temporary file has no (and must have no) security
354-
# implications.
355-
tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
356-
stderr="$tmp/todotxt-external-stderr.$$.tmp"
357-
test_external "$@" 4> "$stderr"
358-
[ -f "$stderr" ] || error "Internal error: $stderr disappeared."
359-
descr="no stderr: $1"
360-
shift
361-
say >&3 "expecting no stderr from previous command"
362-
if [ ! -s "$stderr" ]; then
363-
rm "$stderr"
364-
test_ok_ "$descr"
365-
else
366-
if [ "$verbose" = t ]; then
367-
output=$(echo; echo Stderr is:; cat "$stderr")
368-
else
369-
output=
370-
fi
371-
# rm first in case test_failure exits.
372-
rm "$stderr"
373-
test_failure_ "$descr" "$@" "$output"
374-
fi
375-
}
376-
377319
# This is not among top-level (test_expect_success | test_expect_failure)
378320
# but is a prefix that can be used in the test script, like:
379321
#

0 commit comments

Comments
 (0)