-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathvalidate.sh
More file actions
executable file
·38 lines (31 loc) · 880 Bytes
/
validate.sh
File metadata and controls
executable file
·38 lines (31 loc) · 880 Bytes
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
#!/bin/bash
# Check for unwanted files
for file in *; do
if [[ $file != "main.js" && $file != "main_test.js" && $file != "README.md" && $file != "validate.sh" ]]; then
echo "[!] Unwanted file detected: $file."
exit 1
fi
done
node=$(which node)
test_path="${BASH_SOURCE[0]}"
solution_path="$(realpath .)"
tmp_dir=$(mktemp -d -t lab1-XXXXXXXXXX)
cd $tmp_dir
rm -rf *
cp $solution_path/*.js .
result=$($"node" --test --experimental-test-coverage) ; ret=$?
if [ $ret -ne 0 ] ; then
echo "[!] testing fails."
exit 1
else
coverage=$(echo "$result" | grep 'all files' | awk -F '|' '{print $2}' | sed 's/ //g')
if (( $(echo "$coverage < 100" | bc -l) )); then
echo "[!] Coverage is only $coverage%, should be 100%."
exit 1
else
echo "[V] Coverage is 100%, great job!"
fi
fi
rm -rf $tmp_dir
exit 0
# vim: set fenc=utf8 ff=unix et sw=2 ts=2 sts=2: