about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-07-07 21:34:38 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2022-07-07 23:15:58 +0200
commit50f359c8a189c55e6db5842cb7ec16e801912e68 (patch)
tree47857dc1a67d2e75e349df0430bc176d1488b806
parent0d687bd8294464634724ed1d99bf714188c1a5fc (diff)
downloadrust-50f359c8a189c55e6db5842cb7ec16e801912e68.tar.gz
rust-50f359c8a189c55e6db5842cb7ec16e801912e68.zip
Split tests to have faster CI
-rw-r--r--.github/workflows/ci.yml7
-rwxr-xr-xtest.sh82
2 files changed, 76 insertions, 13 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2e69168dda8..22f67a04e0b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,8 +23,11 @@ jobs:
           "--mini-tests",
           "--std-tests",
           "--test-libcore",
-          "--extended-tests",
-          "--test-successful-rustc",
+          "--extended-rand-tests",
+          "--extended-regex-example-tests",
+          "--extended-regex-tests",
+          "--test-successful-rustc --nb-parts 2 --current-part 0",
+          "--test-successful-rustc --nb-parts 2 --current-part 1",
           "--test-failing-rustc",
         ]
 
diff --git a/test.sh b/test.sh
index 594b63dfd0d..dea9fe412e9 100755
--- a/test.sh
+++ b/test.sh
@@ -19,6 +19,8 @@ gcc_master_branch=1
 channel="debug"
 funcs=()
 build_only=0
+nb_parts=0
+current_part=0
 
 while [[ $# -gt 0 ]]; do
     case $1 in
@@ -77,6 +79,19 @@ while [[ $# -gt 0 ]]; do
             funcs+=(extended_sysroot_tests)
             shift
             ;;
+        "--extended-rand-tests")
+            funcs+=(extended_rand_tests)
+            shift
+            ;;
+        "--extended-regex-example-tests")
+            funcs+=(extended_regex_example_tests)
+            shift
+            ;;
+        "--extended-regex-tests")
+            funcs+=(extended_regex_tests)
+            shift
+            ;;
+
         "--mini-tests")
             funcs+=(mini_tests)
             shift
@@ -90,6 +105,16 @@ while [[ $# -gt 0 ]]; do
             build_only=1
             shift
             ;;
+        "--nb-parts")
+            shift
+            nb_parts=$1
+            shift
+            ;;
+        "--current-part")
+            shift
+            current_part=$1
+            shift
+            ;;
         *)
             echo "Unknown option $1"
             exit 1
@@ -200,7 +225,7 @@ function test_libcore() {
 #echo "[BENCH RUN] mod_bench"
 #hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_*
 
-function extended_sysroot_tests() {
+function extended_rand_tests() {
     if (( $gcc_master_branch == 0 )); then
         return
     fi
@@ -210,17 +235,12 @@ function extended_sysroot_tests() {
     echo "[TEST] rust-random/rand"
     ../cargo.sh test --workspace
     popd
+}
 
-    #pushd simple-raytracer
-    #echo "[BENCH COMPILE] ebobby/simple-raytracer"
-    #hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
-    #"RUSTC=rustc RUSTFLAGS='' cargo build" \
-    #"../cargo.sh build"
-
-    #echo "[BENCH RUN] ebobby/simple-raytracer"
-    #cp ./target/debug/main ./raytracer_cg_gcc
-    #hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_gcc
-    #popd
+function extended_regex_example_tests() {
+    if (( $gcc_master_branch == 0 )); then
+        return
+    fi
 
     pushd regex
     echo "[TEST] rust-lang/regex example shootout-regex-dna"
@@ -232,12 +252,38 @@ function extended_sysroot_tests() {
         | ../cargo.sh run --example shootout-regex-dna \
         | grep -v "Spawned thread" > res.txt
     diff -u res.txt examples/regexdna-output.txt
+    popd
+}
+
+function extended_regex_tests() {
+    if (( $gcc_master_branch == 0 )); then
+        return
+    fi
 
+    pushd regex
     echo "[TEST] rust-lang/regex tests"
+    export CG_RUSTFLAGS="--cap-lints warn" # newer aho_corasick versions throw a deprecation warning
     ../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options -q
     popd
 }
 
+function extended_sysroot_tests() {
+    #pushd simple-raytracer
+    #echo "[BENCH COMPILE] ebobby/simple-raytracer"
+    #hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "cargo clean" \
+    #"RUSTC=rustc RUSTFLAGS='' cargo build" \
+    #"../cargo.sh build"
+
+    #echo "[BENCH RUN] ebobby/simple-raytracer"
+    #cp ./target/debug/main ./raytracer_cg_gcc
+    #hyperfine --runs "${RUN_RUNS:-10}" ./raytracer_cg_llvm ./raytracer_cg_gcc
+    #popd
+
+    extended_rand_tests
+    extended_regex_example_tests
+    extended_regex_tests
+}
+
 function test_rustc() {
     echo
     echo "[TEST] rust-lang/rust"
@@ -297,6 +343,20 @@ EOF
         xargs -a ../failing-ui-tests.txt -d'\n' git checkout --
     fi
 
+    if [ $nb_parts -gt 0 ]; then
+        echo "Splitting ui_test into $nb_parts parts (and running part $current_part)"
+        find src/test/ui -type f -name '*.rs' -not -path "*/auxiliary/*" > ui_tests
+        count=$((`wc -l < ui_tests` / $nb_parts))
+        # We increment the number of tests by one because if this is an odd number, we would skip
+        # one test.
+        count=$((count + 1))
+        split -d -l $count -a 1 ui_tests ui_tests.split
+        # Removing all tests.
+        find src/test/ui -type f -name '*.rs' -not -path "*/auxiliary/*" -exec rm {} \;
+        # Putting back only the ones we want to test.
+        xargs -a "ui_tests.split$current_part" -d'\n' git checkout --
+    fi
+
     echo "[TEST] rustc test suite"
     COMPILETEST_FORCE_STAGE0=1 ./x.py test --run always --stage 0 src/test/ui/ --rustc-args "$RUSTC_ARGS"
 }