-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathsample_code_runner.sh
More file actions
68 lines (63 loc) · 3.14 KB
/
Copy pathsample_code_runner.sh
File metadata and controls
68 lines (63 loc) · 3.14 KB
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
#!/bin/bash
FILECOUNT=0
FAILCOUNT=0
SAMPLECOUNT=1
FAILED_SAMPLES=()
find Samples -print | grep -i -e "\.js$" > list.txt
echo > output.log
while IFS="" read -r p || [ -n "$p" ]
do
if [[ "$p" =~ $(echo ^\($(sed 's/[[:blank:]]//g' sampleCodeIgnoreList.txt | paste -sd '|' /dev/stdin)\)$) ]]; then
printf '\n\n#### SKIPPED - %s ####\n' "$p"
printf '\n\n#### SKIPPED - %s ####\n' "$p" >> output.log
else
printf '\n\n**** RUNNING - %s ****\n' "$p"
printf '\n\n%s **** RUNNING - %s ****\n' "$SAMPLECOUNT" "$p" >> output.log
if node "$p" >> output.log 2>&1; then
printf '\n\n**** END RUNNING - %s ****\n' "$p" >> output.log
FILECOUNT=$((FILECOUNT+1))
else
EXITCODE=$?
printf '\n\n'
printf '################################################################################\n'
printf '################################################################################\n'
printf '### ###\n'
printf '### [SAMPLE CODE FAILED] ###\n'
printf '### %s\n' "$p"
printf '### [SAMPLE CODE FAILED BLOCK] (exit code: %s)\n' "$EXITCODE"
printf '### ###\n'
printf '################################################################################\n'
printf '################################################################################\n'
printf '\n\n'
{
printf '\n\n'
printf '################################################################################\n'
printf '################################################################################\n'
printf '### ###\n'
printf '### [SAMPLE CODE FAILED] ###\n'
printf '### %s\n' "$p"
printf '### [SAMPLE CODE FAILED BLOCK] (exit code: %s)\n' "$EXITCODE"
printf '### ###\n'
printf '################################################################################\n'
printf '################################################################################\n'
printf '\n\n'
} >> output.log
FAILCOUNT=$((FAILCOUNT+1))
FAILED_SAMPLES+=("$p")
fi
fi
SAMPLECOUNT=$((SAMPLECOUNT+1))
done < list.txt
printf '\n\n**** %s Sample Codes ran successfully ****\n' "$FILECOUNT"
printf '\n\n**** %s Sample Codes ran successfully ****\n' "$FILECOUNT" >> output.log
printf '\n\n**** %s Sample Codes FAILED ****\n' "$FAILCOUNT"
printf '\n\n**** %s Sample Codes FAILED ****\n' "$FAILCOUNT" >> output.log
if [ "$FAILCOUNT" -gt 0 ]; then
printf '\n**** List of FAILED Sample Codes: ****\n'
printf '\n**** List of FAILED Sample Codes: ****\n' >> output.log
for failed in "${FAILED_SAMPLES[@]}"; do
printf ' - %s\n' "$failed"
printf ' - %s\n' "$failed" >> output.log
done
fi
rm -f list.txt