-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_end_to_end_tests
executable file
·87 lines (68 loc) · 2.91 KB
/
run_end_to_end_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
79
80
81
82
83
84
85
86
87
#!/bin/bash
trap ctrl_c INT
function ctrl_c() {
echo "Stopping execution of end to end tests"
}
repositories=(
"https://github.com/webdsl/reposearch.git"
"https://github.com/webdsl/yellowgrass.git"
)
function getJARFileName() {
ls spoofax-sunshine/org.metaborg.sunshine2/target/org.metaborg.sunshine2*
}
function runEndToEndTests() {
local jarFile="$1"
for repo in ${repositories[@]}; do
analyzeRepo "$repo" "$jarFile"
done
}
function analyzeRepo() {
local repo="$1"
local jarFile="$2"
local dirName=$(basename $repo .git)
local resultFile="e2e-results/$dirName.txt"
git clone --single-branch --branch experiment/wildcard-imports "$repo" --recurse-submodules
addBuiltInToRepo "$dirName"
java -Xmx4G -Xms4G -Xss64m -jar "$jarFile" build \
-l webdslstatix \
-p "$dirName" \
2>&1 | tee "$resultFile"
prependResultSummary $resultFile $dirName
}
function addBuiltInToRepo() {
local repoDir="$1"
local builtInDir="$repoDir/.servletapp/src-webdsl-template"
if [ ! -f "$builtInDir/built-in.app" ]; then
getLatestBuiltIn
mkdir -p "$builtInDir"
cp "built-in.app" "$builtInDir/built-in.app"
fi
sed -i -e "1s/.*/application $repoDir\n\nimports built-in/" "$repoDir/$repoDir.app"
}
function getLatestBuiltIn() {
if [ ! -f "built-in.app" ]; then
echo "built-in.app does not exist, getting latest version from GitHub."
wget https://raw.githubusercontent.com/webdsl/webdsl/master/src/org/webdsl/dsl/project/template-webdsl/built-in.app \
-q -O "built-in.app"
fi
}
function prependResultSummary() {
local resultFile="$1"
local dirName="$2"
local messageSummary=$(cat "$resultFile" | grep -Eo "[0-9]+ messages.*")
local linesOfCode=$(find $dirName -name '*.app' | xargs wc -l | grep -Eo "[0-9]+ total")
local projectErrors=$(cat "$resultFile" | grep "ERROR in file" | grep -v "built-in.app" | grep -v "/elib/" | wc -l | xargs)
local projectWarnings=$(cat "$resultFile" | grep "WARNING in file" | grep -v "built-in.app" | grep -v "/elib/" | wc -l | xargs)
local builtInErrors=$(cat "$resultFile" | grep "ERROR in file" | grep "built-in.app" | wc -l | xargs)
local builtInWarnings=$(cat "$resultFile" | grep "WARNING in file" | grep "built-in.app" | wc -l | xargs)
local elibErrors=$(cat "$resultFile" | grep "ERROR in file" | grep "/elib/" | wc -l | xargs)
local elibWarnings=$(cat "$resultFile" | grep "WARNING in file" | grep "/elib/" | wc -l | xargs)
printf "$linesOfCode lines of code\n\nResult:\n- Project: $projectErrors errors, $projectWarnings warnings\n- built-in.app: $builtInErrors errors, $builtInWarnings warnings\n- elib: $elibErrors errors, $elibWarnings warnings\n\n$messageSummary\n\n\n\nComplete output:\n\n" | cat - "$resultFile" > tmp.txt && mv tmp.txt "$resultFile"
}
function main() {
local jarFile="$(getJARFileName)"
mkdir e2e-results
runEndToEndTests "$jarFile"
echo "DONE!"
}
main