-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_spt_tests
executable file
·78 lines (63 loc) · 1.95 KB
/
run_spt_tests
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
#!/bin/bash
trap ctrl_c INT
function ctrl_c() {
echo "Stopping execution of tests"
}
function getJARFileName() {
ls spt/org.metaborg.spt.cmd/target/org.metaborg.spt.cmd*
}
function runTests() {
for file in "$1"/*
do
if [ -d "${file}" ] ; then
runTestOnDirectory "$file" "$2"
fi
done
}
function runTestOnDirectory() {
local dirName="$1"
local jarFile="$2"
local dirNameReplaced=$(echo $dirName | sed -e 's/\//__/g')
local resultFile="spt-results/$dirNameReplaced.txt"
echo "Testing $dirName..."
java -Xss32m -jar "$jarFile" \
--lut webdslstatix \
--tests "$dirName" \
--spt spt/org.metaborg.meta.lang.spt \
2>&1 | tee "$resultFile"
prependResultSummary "$resultFile"
}
function prependResultSummary() {
local resultFile="$1"
local lastLine=$(tail -1 $resultFile)
local resultSummary=""
if [[ $lastLine == *"o.m.c.t.LoggingTestReporterService - test result:"* ]]; then
local passed=$(echo $lastLine | grep -Eo "[0-9]+ passed" | grep -Eo "[0-9]+")
local failed=$(echo $lastLine | grep -Eo "[0-9]+ failed" | grep -Eo "[0-9]+")
local ignored=$(echo $lastLine | grep -Eo "[0-9]+ ignored" | grep -Eo "[0-9]+")
resultSummary="Result:\n- passed: $passed\n- failed: $failed\n- ignored: $ignored\n\n\n\nComplete output:\n\n"
else
resultSummary="Tests failed. See detailed output for more information\n\n"
fi
prependLineToFile "$resultSummary" "$resultFile"
}
function prependLineToFile() {
local line="$1"
local file="$2"
printf "$line"|cat - "$file" > tmp.txt && mv tmp.txt "$file"
}
function renameResults {
cd spt-results
for file in * ; do
mv -v "$file" "${file#webdslstatix.test__}"
done
cd ..
}
function main() {
local jarFile="$(getJARFileName)"
mkdir spt-results
runTestOnDirectory "webdslstatix.test/syntax" "$jarFile"
renameResults
echo "DONE!"
}
main