-
Notifications
You must be signed in to change notification settings - Fork 17
/
test.sh
executable file
·59 lines (49 loc) · 1.28 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
#!/bin/bash
function find_js_tests {
find test -type f -iname "*.js" -print0
}
function find_ts_tests {
find test -type f -iname "*.ts" -print0
}
function run_js_test {
node_modules/.bin/mocha ${1} --reporter tap | remove_tap_comments
}
function run_ts_test {
node_modules/.bin/mocha -r ts-node/register ${1} --reporter tap | remove_tap_comments
}
function remove_tap_comments {
grep -v -e '^\s\s'
}
function expected_output {
cat ${1%.*}.txt
}
success=1
while IFS= read -r -d $'\0' scenario; do
actual=$(run_js_test ${scenario})
expected=$(expected_output ${scenario})
differences=$(diff <(echo -e "${actual}") <(echo -e "${expected}"))
if [ -z "${differences}" ]; then
echo "[pass] ${scenario}"
else
echo "[fail] ${scenario}"
echo -e "----\n${differences}\n----"
success=0
fi
done < <(find_js_tests)
while IFS= read -r -d $'\0' scenario; do
actual=$(run_ts_test ${scenario})
expected=$(expected_output ${scenario})
differences=$(diff <(echo -e "${actual}") <(echo -e "${expected}"))
if [ -z "${differences}" ]; then
echo "[pass] ${scenario}"
else
echo "[fail] ${scenario}"
echo -e "----\n${differences}\n----"
success=0
fi
done < <(find_ts_tests)
if [ ${success} -eq 1 ]; then
echo "BUILD SUCCESSFUL"
else
echo "BUILD FAILED"
fi