-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathrunTests.sh
More file actions
executable file
·98 lines (81 loc) · 2.99 KB
/
runTests.sh
File metadata and controls
executable file
·98 lines (81 loc) · 2.99 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
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
96
97
98
#!/bin/bash
# Stop the script if any command fails
set -e
# Function to run tests for a specific configuration
run_tests() {
local libBuildType="$1"
shift
local tasks=("$@")
if [ ${#tasks[@]} -eq 0 ]; then
echo "No specific tasks provided, running all default tests..."
# tasks=("jvmTest" "testDebugUnitTest" "testReleaseUnitTest" "jsTest" "wasmJsTest" "iosX64Test" "iosSimulatorArm64Test" "macosX64Test" "macosArm64Test" "tvosX64Test" "tvosSimulatorArm64Test")
tasks=("jvmTest" "testDebugUnitTest" "jsTest" "wasmJsNodeTest" "macosArm64Test")
fi
echo "Running tests with libBuildType=$libBuildType and tasks=${tasks[*]}..."
# Remove build directories if they exist
echo "clean build"
# Determine which projects to include in testing
local projects=("ksoup-test")
# Only include ksoup-network-test if libBuildType is kotlinx
if [ "$libBuildType" = "kotlinx" ]; then
projects+=("ksoup-network-test")
echo "Including ksoup-network-test module in tests"
else
echo "Skipping ksoup-network-test module (only runs with libBuildType=kotlinx)"
fi
# Clean all relevant projects
local clean_tasks=()
for project in "${projects[@]}"; do
clean_tasks+=("$project:clean")
done
./gradlew "${clean_tasks[@]}" -PlibBuildType="$libBuildType" --quiet --warning-mode=none
for task in "${tasks[@]}"; do
start_time=$(date +%s)
echo "Running $task... $libBuildType"
# Build the project list for this task
local project_tasks=()
for project in "${projects[@]}"; do
project_tasks+=("$project:$task")
done
# Run the task on the selected projects
./gradlew "${project_tasks[@]}" -PlibBuildType="$libBuildType" --quiet --warning-mode=none
end_time=$(date +%s)
duration=$((end_time - start_time))
echo "Task $task completed in $duration seconds."
done
}
# Supported parameters
SUPPORTED_PARAMS=("core" "okio" "kotlinx")
# Function to check if the provided parameter is supported
is_supported_param() {
local param="$1"
for supported_param in "${SUPPORTED_PARAMS[@]}"; do
if [ "$supported_param" == "$param" ]; then
return 0
fi
done
return 1
}
# Main script logic
if [ "$#" -ge 1 ]; then
libBuildType="$1"
shift
if is_supported_param "$libBuildType"; then
# If there's only one argument left and it contains spaces, split it into an array
if [ "$#" -eq 1 ] && [[ "$1" == *" "* ]]; then
# Split the string into an array using space as delimiter
IFS=' ' read -r -a task_array <<< "$1"
run_tests "$libBuildType" "${task_array[@]}"
else
run_tests "$libBuildType" "$@"
fi
else
echo "Error: Unsupported parameter '$libBuildType'. Supported parameters are: ${SUPPORTED_PARAMS[*]}"
exit 1
fi
else
for param in "${SUPPORTED_PARAMS[@]}"; do
run_tests "$param"
done
fi
echo "All tests ran successfully!"