-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·81 lines (71 loc) · 2.21 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
# Rather crude test harness for `falderal` itself.
run_falderal_integration_tests() {
FALDERAL="$1"
FIRST_TESTS="
test-pass-fail test-no-functionality test-ill-formed test-no-test-body
test-var-subst test-no-eol
test-utf8 test-crlf
test-bad-indentation
test-input-sections test-shared-body
test-stdout-stderr test-err-no-stderr
test-freestyle-format
"
for TEST in ${FIRST_TESTS}; do
echo ${TEST}...
$FALDERAL --cavalier ${TEST}.markdown > ${TEST}.actual 2>&1
diff -u ${TEST}.expected ${TEST}.actual || exit 1
done
# tests for linting
LINTING_TESTS="test-no-tests"
for TEST in ${LINTING_TESTS}; do
echo ${TEST}...
$FALDERAL ${TEST}.markdown > ${TEST}.actual 2>&1
diff -u ${TEST}.expected ${TEST}.actual || exit 1
done
TWO_PART_TESTS="
test-no-functionality-leak test-implementations-global test-appliances
"
for TEST in ${TWO_PART_TESTS}; do
echo ${TEST}...
$FALDERAL ${TEST}-a.markdown ${TEST}-b.markdown > ${TEST}.actual 2>&1
diff -u ${TEST}.expected ${TEST}.actual || exit 1
done
# special tests: -b
TEST=test-substring-error
echo ${TEST}...
$FALDERAL -b ${TEST}.markdown > ${TEST}.actual 2>&1
diff -u ${TEST}.expected ${TEST}.actual || exit 1
}
run_falderal_tests() {
PYTHON="$1"
PYTHONPATH=src $PYTHON src/falderal/tests.py -v || exit 1
( cd tests && run_falderal_integration_tests "$PYTHON ../bin/falderal" )
}
### Main ###
if [ "x$PYTHON" != "x" ]; then
if command -v "$PYTHON" > /dev/null 2>&1; then
run_falderal_tests "$PYTHON" || exit 1
else
echo "$PYTHON not found on executable search path. Aborting."
exit 1
fi
else
MISSING=""
if command -v python2 > /dev/null 2>&1; then
run_falderal_tests "python2" || exit 1
else
MISSING="${MISSING}2"
fi
if command -v python3 > /dev/null 2>&1; then
run_falderal_tests "python3" || exit 1
else
MISSING="${MISSING}3"
fi
if [ "x${MISSING}" = "x23" ]; then
echo "Neither python2 nor python3 found on executable search path. Aborting."
exit 1
fi
fi
rm -f *.actual
echo 'All tests passed.'