File tree Expand file tree Collapse file tree 2 files changed +34
-14
lines changed Expand file tree Collapse file tree 2 files changed +34
-14
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # get_test_half returns either the first or second half of integration tests
4+ # Usage: get_test_half <half_number>
5+ # half_number: 0 for first half, 1 for second half
6+ get_test_half () {
7+ local half_number=$1
8+ # Ensure only spec files go to stdout
9+ pushd qa/integration > /dev/null 2>&1
10+
11+ # Collect all spec files
12+ local glob1=(specs/* spec.rb)
13+ local glob2=(specs/** /* spec.rb)
14+ local all_specs=(" ${glob1[@]} " " ${glob2[@]} " )
15+
16+ # Calculate the split point
17+ local split_point=$(( ${# all_specs[@]} / 2 ))
18+
19+ # Get the requested half (:: is "up to", : is "from")
20+ if [[ $half_number -eq 0 ]]; then
21+ local specs=" ${all_specs[@]:: $split_point } "
22+ else
23+ local specs=" ${all_specs[@]: $split_point } "
24+ fi
25+ popd > /dev/null 2>&1
26+ echo " $specs "
27+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ export GRADLE_OPTS="-Xmx2g -Dorg.gradle.jvmargs=-Xmx2g -Dorg.gradle.daemon=false
1010export SPEC_OPTS=" --order rand --format documentation"
1111export CI=true
1212
13+ # Source shared function for splitting integration tests
14+ source " $( dirname " ${BASH_SOURCE[0]} " ) /get-test-half.sh"
15+
1316if [ -n " $BUILD_JAVA_HOME " ]; then
1417 GRADLE_OPTS=" $GRADLE_OPTS -Dorg.gradle.java.home=$BUILD_JAVA_HOME "
1518fi
@@ -19,20 +22,10 @@ if [[ $1 = "setup" ]]; then
1922 exit 0
2023
2124elif [[ $1 == " split" ]]; then
22- cd qa/integration
23- glob1=(specs/* spec.rb)
24- glob2=(specs/** /* spec.rb)
25- all_specs=(" ${glob1[@]} " " ${glob2[@]} " )
26-
27- specs0=${all_specs[@]:: $((${# all_specs[@]} / 2 ))}
28- specs1=${all_specs[@]: $((${# all_specs[@]} / 2 ))}
29- cd ../..
30- if [[ $2 == 0 ]]; then
31- echo " Running the first half of integration specs: $specs0 "
32- ./gradlew runIntegrationTests -PrubyIntegrationSpecs=" $specs0 " --console=plain
33- elif [[ $2 == 1 ]]; then
34- echo " Running the second half of integration specs: $specs1 "
35- ./gradlew runIntegrationTests -PrubyIntegrationSpecs=" $specs1 " --console=plain
25+ if [[ $2 =~ ^[01]$ ]]; then
26+ specs=$( get_test_half " $2 " )
27+ echo " Running half $2 of integration specs: $specs "
28+ ./gradlew runIntegrationTests -PrubyIntegrationSpecs=" $specs " --console=plain
3629 else
3730 echo " Error, must specify 0 or 1 after the split. For example ci/integration_tests.sh split 0"
3831 exit 1
You can’t perform that action at this time.
0 commit comments