-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
ci.sh
executable file
·95 lines (86 loc) · 2.92 KB
/
ci.sh
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
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
set -eE
trap 'echo ERROR: $BASH_SOURCE:$LINENO $BASH_COMMAND >&2;' ERR
function validateSingleTestRun() {
testCommand=$1
testCommandArgsString=$2
suits=$3
suitsTotal=$4
tests=$5
testsTotal=$6
testsSkipped=$7
testsSuitesSkipped=$8
additionalStep=$9
IFS=';' read -ra testCommandArgs <<<"$testCommandArgsString"
set -x
${testCommand} ${ngTestParams} "${testCommandArgs[@]}" 2>&1 | tee tests.log
set +x
if [[ ! -z ${additionalStep} ]]; then
${additionalStep}
fi
testPrefix="Tests: "
if [[ ! -z ${testsSkipped} ]]; then
echo inside: $7
testPrefix="${testPrefix}${testsSkipped} skipped, "
fi
testSuitesPrefix="Test Suites: "
if [[ ! -z ${testsSuitesSkipped} ]]; then
echo inside: $7
testSuitesPrefix="${testSuitesPrefix}${testsSuitesSkipped} skipped, "
fi
set -x
grep -q "${testSuitesPrefix}${suits} passed, ${suitsTotal} total" ./tests.log
grep -q "${testPrefix}${tests} passed, ${testsTotal} total" ./tests.log
set +x
}
function validateAllTestRuns() {
local -n allTests=$1
ngTestParams=$2
for testOpt in "${allTests[@]}"; do
IFS='|' read -ra testParams <<<"$testOpt"
validateSingleTestRun "${testParams[@]}" "${ngTestParams}"
done
}
function ciApp() {
appDir=$1
local -n testOptions=$2
ngTestParams=$3
packagePath=$(realpath --relative-to="$appDir" "$(pwd)/${filename}")
(
cd ${appDir}
validateAllTestRuns testOptions ${ngTestParams}
set -x
yarn e2e
set +x
)
}
function checkJunit() {
if [[ -f ./junit.xml ]]; then
rm -f ./junit.xml
else
echo "ERROR: junit.xml was not created"
exit 1
fi
}
simpleAppTestOptions=(
"yarn test|--no-cache|2|2|4|4||||"
"yarn test|--test-name-pattern=^AppComponent should create the app$|1|1 of 2|1|4|3|1||"
"yarn test|--reporters=default;--reporters=jest-junit|2|2|4|4|||checkJunit"
"yarn test|--shard=1/2|1|1|1|1|||"
"yarn test|--shard=2/2|1|1|3|3|||"
)
multiAppTestOptions=(
"yarn test my-first-app||1|1|3|3|||"
"yarn test my-second-app||1|1|3|3|||"
"yarn test my-shared-library||2|2|2|2|||"
"yarn test my-first-app|--test-name-pattern=^AppComponent should create the app$|1|1|1|3|2||"
"yarn test my-shared-library|--test-path-pattern=src/lib/my-shared-library.service.spec.ts$|1|1|1|1|||"
"yarn test my-shared-library|--test-path-pattern=src/lib/my-shared-library.component.spec.ts$;--test-path-pattern=src/lib/my-shared-library.service.spec.ts$|2|2|2|2|||"
"yarn test my-shared-library|--find-related-tests;src/lib/my-shared-library.service.ts,src/lib/my-shared-library.component.ts|2|2|2|2|||"
)
cd ../../examples/jest/simple-app
yarn test:ts
yarn test:esm
cd ../../../packages/jest
(ciApp ../../examples/jest/simple-app simpleAppTestOptions)
(ciApp ../../examples/jest/multiple-apps multiAppTestOptions)