Skip to content

Commit 113b518

Browse files
committed
Improve test runner
Test that fail runs actually fail intendedly and not segfault Improve output by adding an indent Fix osx compatibility
1 parent 592ef39 commit 113b518

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

test/run_tests.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -euo pipefail
44

5-
PASS_FILES=$(find pass_files -name "*.d")
6-
FAIL_FILES=$(find fail_files -name "*.d")
5+
PASS_FILES=$(find pass_files -name "*.d" | sort)
6+
FAIL_FILES=$(find fail_files -name "*.d" | sort)
77
PASS_COUNT=0
88
FAIL_COUNT=0
99
NORMAL="\033[01;0m"
@@ -18,25 +18,37 @@ echo -en "Compiling parse tester... "
1818
${DMD} tester.d $SOURCE_FILES -g $IMPORT_PATHS
1919
echo -e "${GREEN}DONE${NORMAL}"
2020

21+
test_fail() {
22+
set +e
23+
./tester "$@"
24+
test_fail_status=$?
25+
set -e
26+
if [ $test_fail_status -eq 1 ]; then
27+
return 0
28+
else
29+
return 1
30+
fi
31+
}
32+
2133
for i in $PASS_FILES; do
2234
echo -en "Parsing $i..."
2335
if ./tester "$i" 2>/dev/null 1>/dev/null; then
24-
echo -e "${GREEN}PASS${NORMAL}"
36+
echo -e "\t${GREEN}PASS${NORMAL}"
2537
((PASS_COUNT=PASS_COUNT+1))
2638
else
27-
echo -e "${RED}FAIL${NORMAL}"
39+
echo -e "\t${RED}FAIL${NORMAL}"
2840
((FAIL_COUNT=FAIL_COUNT+1))
2941
fi
3042
done
3143

3244
for i in $FAIL_FILES; do
3345
echo -en "Parsing $i..."
34-
if ./tester "$i" 2>/dev/null 1>/dev/null; then
35-
echo -e "${RED}FAIL${NORMAL}"
36-
((FAIL_COUNT=FAIL_COUNT+1))
37-
else
38-
echo -e "${GREEN}PASS${NORMAL}"
46+
if test_fail "$i" 2>/dev/null 1>/dev/null; then
47+
echo -e "\t${GREEN}PASS${NORMAL}"
3948
((PASS_COUNT=PASS_COUNT+1))
49+
else
50+
echo -e "\t${RED}FAIL${NORMAL}"
51+
((FAIL_COUNT=FAIL_COUNT+1))
4052
fi
4153
done
4254

@@ -110,7 +122,7 @@ find . -name "*.lst" | while read -r i; do
110122
done
111123
echo -e "${GREEN}DONE${NORMAL}"
112124
for i in coverage/*.lst; do
113-
tail "$i" -n1
125+
tail -n1 "$i"
114126
done
115127

116128
rm -f tester.o

0 commit comments

Comments
 (0)