Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Extract randomized test CI process into a script

Max Brunsfeldc329546570af
diff --git a/.github/workflows/randomized_tests.yml b/.github/workflows/randomized_tests.yml
index b9f5bbcbd37..3b3d3b21cd9 100644
--- a/.github/workflows/randomized_tests.yml
+++ b/.github/workflows/randomized_tests.yml
@@ -14,8 +14,6 @@ env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
- OPERATIONS: 200
- ITERATIONS: 10000
jobs:
tests:
@@ -40,12 +38,5 @@ jobs:
clean: false
submodules: 'recursive'
- - name: Select seed
- run: |
- set -eu
- seed=$(od -A n -N 8 -t u8 /dev/urandom | xargs)
- echo "seed: ${seed}"
- echo "SEED=${seed}" >> $GITHUB_ENV
-
- - name: Run tests
- run: cargo test --release --package collab random
+ - name: Run randomized tests
+ run: script/randomized-test-ci
diff --git a/crates/gpui/src/test.rs b/crates/gpui/src/test.rs
index 372131b06c4..cacb8a435a9 100644
--- a/crates/gpui/src/test.rs
+++ b/crates/gpui/src/test.rs
@@ -76,7 +76,7 @@ pub fn run_test(
let seed = atomic_seed.load(SeqCst);
if is_randomized {
- dbg!(seed);
+ eprintln!("seed = {seed}");
}
let deterministic = executor::Deterministic::new(seed);
diff --git a/script/randomized-test-ci b/script/randomized-test-ci
new file mode 100755
index 00000000000..e8837d42b2b
--- /dev/null
+++ b/script/randomized-test-ci
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Compile the tests first
+mkdir -p target
+cargo test --release --package collab --no-run
+if [[ $? != 0 ]]; then
+ echo "Build failed"
+ exit 1
+fi
+
+set -eu
+
+LOG_FILE=target/randomized-tests.log
+export SAVE_PLAN=target/test-plan.json
+export OPERATIONS=200
+export ITERATIONS=10000
+export SEED=$(od -A n -N 8 -t u8 /dev/urandom | xargs)
+
+cargo test --release --package collab random -- --nocapture 2> >(tee $LOG_FILE)
+if [[ $? == 0 ]]; then
+ echo "Tests passed"
+ exit 0
+fi
+
+# If the tests failed, find the failing seed in the logs
+failing_seed=$(grep "failing seed" $LOG_FILE | cut -d: -f2 | xargs)
+echo "Tests failed. seed: $failing_seed"