-
Notifications
You must be signed in to change notification settings - Fork 17
/
startTestEnv
executable file
·68 lines (57 loc) · 1.97 KB
/
startTestEnv
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
function cleanup {
if [[ $cicd = true ]]; then
./utils/cleanTestEnv --cicd
else
./utils/cleanTestEnv --local
fi
}
usage="Usage: startTestEnv [--help] [--wait] [--silent] [--cicd] [--force]"
wait=false
silent=false
cicd=false
force=false
# Based on https://stackoverflow.com/a/33826763/11827673
while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) echo "$usage"; exit ;;
-w|--wait) wait=true ;;
-s|--silent) silent=true ;;
-c|--cicd) cicd=true ;;
-f|--force) force=true ;;
*) echo "Unknown parameter passed: $1"; echo "$usage"; exit 1 ;;
esac
shift
done
if [[ $force = true && -f .testEnvRunning ]]; then
[[ $silent = false ]] && echo "Removing previous testing environment..."
cleanup
fi
trap cleanup EXIT
[[ $silent = false ]] && echo "Setting up testing environment..."
if [[ $cicd = true ]]; then
./utils/setupTestEnv --cicd
else
./utils/setupTestEnv --local
fi
if [[ $wait = true ]]; then
[[ $silent = false ]] && echo "Test environment started! Leave this script running while running tests."
# Wait for the user to end the session
while true; do
sleep 1
done
else
[[ $silent = false ]] && echo "Running all tests..."
if [[ $cicd = true ]]; then
# Get list of classnames of tests that should run on this node.
circleci tests glob "supertokens-*/src/test/**/*.java" | cut -c 1- | sed 's@/@.@g' | sed 's/.\{5\}$//' |
sed 's/^.*io\.supertokens/io.supertokens/' |
circleci tests run --command=">classnames.txt xargs echo" --verbose --split-by=timings --timings-type=classname
#if this is a re-run and it is a parallel run that does not have tests to run, halt execution of this parallel run
[ -s classnames.txt ] || { circleci-agent step halt && exit 0; }
GRADLE_ARGS=$(cat classnames.txt | awk '{for (i=1; i<=NF; i++) print "--tests",$i}')
echo "Prepared arguments for Gradle: $GRADLE_ARGS"
fi
# Tests are run relative to the project's folder
./gradlew test $GRADLE_ARGS
fi