git @ Cat's Eye Technologies Falderal / 087d093
Test under python2, or under python3, if both if both are installed. Chris Pressey 6 months ago
1 changed file(s) with 74 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
11
22 # Really crude test harness for py-falderal itself...
33
4 if [ "x$PYTHON" = "x" ]; then
5 PYTHON="python3"
4 run_falderal_integration_tests() {
5 FALDERAL="$1"
6
7 FIRST_TESTS="
8 test-pass-fail test-no-functionality test-ill-formed test-no-test-body
9 test-var-subst test-no-eol
10 test-utf8 test-crlf
11 test-bad-indentation
12 test-input-sections test-shared-body
13 test-stdout-stderr test-err-no-stderr
14 test-freestyle-format
15 "
16 for TEST in ${FIRST_TESTS}; do
17 echo ${TEST}...
18 $FALDERAL --cavalier ${TEST}.markdown > ${TEST}.actual 2>&1
19 diff -u ${TEST}.expected ${TEST}.actual || exit 1
20 done
21
22 # tests for linting
23 LINTING_TESTS="test-no-tests"
24 for TEST in ${LINTING_TESTS}; do
25 echo ${TEST}...
26 $FALDERAL ${TEST}.markdown > ${TEST}.actual 2>&1
27 diff -u ${TEST}.expected ${TEST}.actual || exit 1
28 done
29
30 TWO_PART_TESTS="
31 test-no-functionality-leak test-implementations-global test-appliances
32 "
33 for TEST in ${TWO_PART_TESTS}; do
34 echo ${TEST}...
35 $FALDERAL ${TEST}-a.markdown ${TEST}-b.markdown > ${TEST}.actual 2>&1
36 diff -u ${TEST}.expected ${TEST}.actual || exit 1
37 done
38
39 # special tests: -b
40 TEST=test-substring-error
41 echo ${TEST}...
42 $FALDERAL -b ${TEST}.markdown > ${TEST}.actual 2>&1
43 diff -u ${TEST}.expected ${TEST}.actual || exit 1
44 }
45
46 run_falderal_tests() {
47 PYTHON="$1"
48 PYTHONPATH=src $PYTHON src/falderal/tests.py -v || exit 1
49 ( cd tests && run_falderal_integration_tests "$PYTHON ../bin/falderal" )
50 }
51
52 ### Main ###
53
54 if [ "x$PYTHON" != "x" ]; then
55 if command -v "$PYTHON" > /dev/null 2>&1; then
56 run_falderal_tests "$PYTHON" || exit 1
57 else
58 echo "$PYTHON not found on executable search path. Aborting."
59 exit 1
60 fi
61 run_falderal_tests "$PYTHON"
62 else
63 MISSING=""
64 if command -v python2 > /dev/null 2>&1; then
65 run_falderal_tests "python2" || exit 1
66 else
67 MISSING="${MISSING}2"
68 fi
69 if command -v python3 > /dev/null 2>&1; then
70 run_falderal_tests "python3" || exit 1
71 else
72 MISSING="${MISSING}3"
73 fi
74 if [ "x${MISSING}" = "x23" ]; then
75 echo "Neither python2 nor python3 found on executable search path. Aborting."
76 exit 1
77 fi
678 fi
7 FALDERAL="$PYTHON ../bin/falderal"
8
9 PYTHONPATH=src $PYTHON src/falderal/tests.py -v || exit 1
10
11 cd tests
12
13 FIRST_TESTS="
14 test-pass-fail test-no-functionality test-ill-formed test-no-test-body
15 test-var-subst test-no-eol
16 test-utf8 test-crlf
17 test-bad-indentation
18 test-input-sections test-shared-body
19 test-stdout-stderr test-err-no-stderr
20 test-freestyle-format
21 "
22 for TEST in ${FIRST_TESTS}; do
23 echo ${TEST}...
24 $FALDERAL --cavalier ${TEST}.markdown > ${TEST}.actual 2>&1
25 diff -u ${TEST}.expected ${TEST}.actual || exit 1
26 done
27
28 # tests for linting
29 LINTING_TESTS="test-no-tests"
30 for TEST in ${LINTING_TESTS}; do
31 echo ${TEST}...
32 $FALDERAL ${TEST}.markdown > ${TEST}.actual 2>&1
33 diff -u ${TEST}.expected ${TEST}.actual || exit 1
34 done
35
36 TWO_PART_TESTS="
37 test-no-functionality-leak test-implementations-global test-appliances
38 "
39 for TEST in ${TWO_PART_TESTS}; do
40 echo ${TEST}...
41 $FALDERAL ${TEST}-a.markdown ${TEST}-b.markdown > ${TEST}.actual 2>&1
42 diff -u ${TEST}.expected ${TEST}.actual || exit 1
43 done
44
45 # special tests: -b
46 TEST=test-substring-error
47 echo ${TEST}...
48 $FALDERAL -b ${TEST}.markdown > ${TEST}.actual 2>&1
49 diff -u ${TEST}.expected ${TEST}.actual || exit 1
5079
5180 rm -f *.actual
5281 echo 'All tests passed.'