-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·104 lines (90 loc) · 2.38 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ./test.sh :Run all the tests.
# ./test.sh -g 1 :Run only general tests
# ./test.sh -e 1 :Run only end to end tests for all the suits in test/endToEnd
# ./test.sh -e 1 -f "suiteName" :Run only end to end tests for a specific suit
while getopts ":g:e:f:" opt; do
case $opt in
g) generalTests="$OPTARG"
;;
e) endToEndTests="$OPTARG"
;;
f) specificSuit="$OPTARG"
;;
\?) echo "Invalid argument -$OPTARG" >&2
;;
esac
done
endToEnd() {
echo "Running for $1"
dir=test/endToEnd/$1
protoc --chpl_out=$dir $dir/protoFile/$1.proto || exit 1
protoc -I=$dir/protoFile/ --python_out=$dir $dir/protoFile/$1.proto || exit 1
#write from chapel and read from chapel
echo "Chapel to chapel"
chpl -o $dir/write $dir/write.chpl || exit 1
$dir/./write
chpl -o $dir/read $dir/read.chpl || exit 1
OUTPUT="$($dir/./read)"
rm -r $dir/write
rm -r $dir/read
rm -r out
if echo $OUTPUT | grep -q 'false'; then
echo "tests failed for chapel to chapel"
exit 1
else
echo "chapel to chapel passed"
echo "======================="
fi
#write from chapel and read from python
echo "chapel to python"
chpl -o $dir/write $dir/write.chpl || exit 1
$dir/./write
OUTPUT="$(python3 $dir/read.py)" || exit 1
rm -r $dir/write
rm -r out
if echo $OUTPUT | grep -q 'false'; then
echo "tests failed for chapel to python"
exit 1
else
echo "chapel to python passed"
echo "======================="
fi
#write from python and read from chapel
echo "python to chapel"
python3 $dir/write.py || exit 1
chpl -o $dir/read $dir/read.chpl || exit 1
OUTPUT="$($dir/./read)"
rm -r $dir/read
rm -r out
if echo $OUTPUT | grep -q 'false'; then
echo "tests failed for python to chapel"
exit 1
else
echo "python to chapel passed"
echo "======================="
fi
#remove files generated by protoc
rm -r $dir/$1*
}
if [ -z "$endToEndTests" ]; then
echo "running general tests "
OUTPUT="$(start_test test/general)"
if echo $OUTPUT | grep -q '#Failures = 0'; then
echo "All general tests passed."
echo "======================="
else
echo "general tests failed"
exit 1
fi
fi
if [ -z "$generalTests" ]; then
echo "running end to end tests"
if [ ! -z "$specificSuit" ]; then
endToEnd $specificSuit
else
for suite in "test/endToEnd"/*
do
endToEnd $(basename $suite)
done
fi
fi