Fix portability issues in test runner script
This commit is contained in:
parent
6621d8ef36
commit
d3e36c51d6
3 changed files with 41 additions and 35 deletions
2
Makefile
2
Makefile
|
@ -45,7 +45,7 @@ src/html_blocks.c: html_block_names.gperf
|
|||
# Testing
|
||||
|
||||
test: hoedown
|
||||
test/runner.bash ./hoedown test/MarkdownTest_1.0.3/Tests
|
||||
test/runner.sh ./hoedown test/MarkdownTest_1.0.3/Tests
|
||||
|
||||
test-pl: hoedown
|
||||
perl test/MarkdownTest_1.0.3/MarkdownTest.pl \
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
TIDY='tidy --show-body-only 1 --quiet 1 --show-warnings 0'
|
||||
SCRIPT="$1"
|
||||
TESTDIR="$2"
|
||||
PASSED=0
|
||||
FAILED=0
|
||||
|
||||
abort() {
|
||||
echo "Error: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -f "$SCRIPT" || abort "argument #1 invalid; not a file"
|
||||
test -x "$SCRIPT" || abort "argument #1 invalid; not executable"
|
||||
"$SCRIPT" <<< "" || abort "argument #1 invalid; script failed to run"
|
||||
test -d "$TESTDIR" || abort "argument #2 invalid; not a directory"
|
||||
|
||||
for TEXT in "$TESTDIR"/*.text; do
|
||||
test -f "$TEXT" || abort "empty or invalid test directory"
|
||||
printf "$(basename "$TEXT" .text) ... "
|
||||
HTML="${TEXT/%.text/.html}"
|
||||
DIFF=`diff <($SCRIPT "$TEXT" | $TIDY) <($TIDY "$HTML")`
|
||||
if test $? == 0; then
|
||||
((PASSED++))
|
||||
echo OK
|
||||
else
|
||||
((FAILED++))
|
||||
echo FAILED
|
||||
printf "\n$DIFF\n\n"
|
||||
fi
|
||||
done
|
||||
|
||||
printf "\n\n$PASSED passed; $FAILED failed.\n"
|
40
test/runner.sh
Executable file
40
test/runner.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
|
||||
POSIXLY_CORRECT=1
|
||||
export POSIXLY_CORRECT
|
||||
|
||||
TIDY='tidy --show-body-only 1 --quiet 1 --show-warnings 0'
|
||||
SCRIPT="$1"
|
||||
TESTDIR="$2"
|
||||
PASSED=0
|
||||
FAILED=0
|
||||
|
||||
abort() {
|
||||
echo "Error: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -f "$SCRIPT" || abort "argument #1 invalid; not a file"
|
||||
test -x "$SCRIPT" || abort "argument #1 invalid; not executable"
|
||||
echo "" | "$SCRIPT" || abort "argument #1 invalid; script failed to run"
|
||||
test -d "$TESTDIR" || abort "argument #2 invalid; not a directory"
|
||||
|
||||
for TEXT in "$TESTDIR"/*.text; do
|
||||
test -f "$TEXT" || abort "empty or invalid test directory"
|
||||
printf "$(basename "$TEXT" .text) ... "
|
||||
HTML=$(echo "$TEXT" | sed 's/\.text$/.html/')
|
||||
mkfifo .pipe
|
||||
$SCRIPT "$TEXT" | $TIDY > .pipe &
|
||||
DIFF=$($TIDY "$HTML" | diff .pipe -)
|
||||
if test "$?" = 0; then
|
||||
PASSED=$(expr $PASSED + 1)
|
||||
echo OK
|
||||
else
|
||||
FAILED=$(expr $FAILED + 1)
|
||||
echo FAILED
|
||||
printf "\n$DIFF\n\n"
|
||||
fi
|
||||
rm .pipe
|
||||
done
|
||||
|
||||
printf "\n\n$PASSED passed; $FAILED failed.\n"
|
Loading…
Reference in a new issue