Skip to content

Commit 280e453

Browse files
committed
run tests sequentially
1 parent 41d66b2 commit 280e453

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ jobs:
3636
if: contains(matrix.os, 'ubuntu')
3737
run: |
3838
cargo fmt -- --check
39-
39+
4040
- name: Check builds Wasm
4141
if: contains(matrix.os, 'ubuntu')
4242
run: |
4343
rustup target add wasm32-unknown-unknown
4444
cargo check --all-features --target wasm32-unknown-unknown
4545
46+
# Some tests mutate the current working directory while some others rely
47+
# on it; we run them sequentially to avoid flakiness.
4648
- name: Cargo test
47-
run: cargo test --locked --release --all-features --bins --tests --examples
49+
run: cargo test --locked --release --all-features --bins --tests --examples -- --test-threads=1
4850

4951
- name: Lint
5052
if: contains(matrix.os, 'ubuntu')

src/fs.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ mod test {
176176

177177
use sys_traits::impls::InMemorySys;
178178
use sys_traits::impls::RealSys;
179+
use sys_traits::EnvCurrentDir;
179180
use sys_traits::EnvSetCurrentDir;
180181
use sys_traits::FsCanonicalize;
181182
use sys_traits::FsCreateDirAll;
@@ -221,11 +222,17 @@ mod test {
221222
assert_eq!(path, PathBuf::from("/a/b/c/d/e"));
222223
}
223224

225+
// Note: this test mutates the current working directory. Although it will be
226+
// restored at the end, if other tests relying on the cwd are run in parallel
227+
// to this test, they may fail.
224228
#[test]
225229
fn test_canonicalize_path_maybe_not_exists_real() {
226230
let sys = RealSys;
227231
let temp_dir = tempfile::tempdir().unwrap();
228232

233+
// Save the original working directory to restore it later
234+
let original_cwd = sys.env_current_dir().unwrap();
235+
229236
// .
230237
// ├── a
231238
// │ └── b
@@ -265,6 +272,9 @@ mod test {
265272
let path =
266273
canonicalize_path_maybe_not_exists(&sys, Path::new("./d/e")).unwrap();
267274
assert_eq!(path, canonicalized_temp_dir_path.join("a/b/c/d/e"));
275+
276+
// Restore the original working directory
277+
sys.env_set_current_dir(&original_cwd).unwrap();
268278
}
269279

270280
#[test]

0 commit comments

Comments
 (0)