Skip to content

Commit 8eb6ea9

Browse files
committed
fix: eol of lab1/validate.sh
1 parent 25d1bb1 commit 8eb6ea9

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# 112-spring-software-testing-and-secure-programming
2+
23
Labs for NYCU "Software Testing and Secure Programming" course in 112 spring

lab1/validate.sh

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
#!/bin/bash
2-
3-
# Check for unwanted files
4-
for file in *; do
5-
if [[ $file != "main.js" && $file != "main_test.js" && $file != "README.md" && $file != "validate.sh" ]]; then
6-
echo "[!] Unwanted file detected: $file."
7-
exit 1
8-
fi
9-
done
10-
11-
node=$(which node)
12-
test_path="${BASH_SOURCE[0]}"
13-
solution_path="$(realpath .)"
14-
tmp_dir=$(mktemp -d -t lab1-XXXXXXXXXX)
15-
16-
cd $tmp_dir
17-
18-
rm -rf *
19-
cp $solution_path/*.js .
20-
result=$($"node" --test --experimental-test-coverage) ; ret=$?
21-
if [ $ret -ne 0 ] ; then
22-
echo "[!] testing fails."
23-
exit 1
24-
else
25-
coverage=$(echo "$result" | grep 'all files' | awk -F '|' '{print $2}' | sed 's/ //g')
26-
if (( $(echo "$coverage < 100" | bc -l) )); then
27-
echo "[!] Coverage is only $coverage%, should be 100%."
28-
exit 1
29-
else
30-
echo "[V] Coverage is 100%, great job!"
31-
fi
32-
fi
33-
34-
rm -rf $tmp_dir
35-
36-
exit 0
37-
1+
#!/bin/bash
2+
3+
# Check for unwanted files
4+
for file in *; do
5+
if [[ $file != "main.js" && $file != "main_test.js" && $file != "README.md" && $file != "validate.sh" ]]; then
6+
echo "[!] Unwanted file detected: $file."
7+
exit 1
8+
fi
9+
done
10+
11+
node=$(which node)
12+
test_path="${BASH_SOURCE[0]}"
13+
solution_path="$(realpath .)"
14+
tmp_dir=$(mktemp -d -t lab1-XXXXXXXXXX)
15+
16+
cd $tmp_dir
17+
18+
rm -rf *
19+
cp $solution_path/*.js .
20+
result=$($"node" --test --experimental-test-coverage) ; ret=$?
21+
if [ $ret -ne 0 ] ; then
22+
echo "[!] testing fails."
23+
exit 1
24+
else
25+
coverage=$(echo "$result" | grep 'all files' | awk -F '|' '{print $2}' | sed 's/ //g')
26+
if (( $(echo "$coverage < 100" | bc -l) )); then
27+
echo "[!] Coverage is only $coverage%, should be 100%."
28+
exit 1
29+
else
30+
echo "[V] Coverage is 100%, great job!"
31+
fi
32+
fi
33+
34+
rm -rf $tmp_dir
35+
36+
exit 0
37+
3838
# vim: set fenc=utf8 ff=unix et sw=2 ts=2 sts=2:

0 commit comments

Comments
 (0)