Skip to content

Commit f4c0b5a

Browse files
committed
Tests: Trim two tests that crossed the 8 s nextest cap
Both tests passed in isolation but timed out when `./scripts/check.sh` ran them under its full parallel-check contention. The 8 s cap is intentional (see `.config/nextest.toml`); the policy is to refactor the workload, not to bump it. Confirmed by three back-to-back green runs after the change. - `file_system::volume::in_memory_test::test_concurrent_reads`: 10 tasks × 100 iters (~1 M `RwLock<HashMap>` ops + entry materialisations) → 10 × 25 iters (250 interleavings, still plenty of pressure to surface a race). Was 2.0 s in isolation; trimmed to ~1.25 s, comfortably under cap. - `file_system::git::m3_tests::commits_listing_cancellation_polls_atomic_flag`: `build_simple_repo(20)` (≈31 `git` shell-outs) → `build_simple_repo(5)`. With the cancel flag pre-set, even 5 commits is enough to prove the walk got cut short (`entries.len() < 5`). The fixture build dominated; the listing call itself is microseconds. - Also included: an `oxfmt` reflow of the CLAUDE.md selection note that landed in the previous commit (auto-fixed by check.sh).
1 parent 5cecfd6 commit f4c0b5a

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

apps/desktop/src-tauri/src/file_system/git/m3_tests.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,14 @@ fn commits_caps_listing_at_max() {
129129
#[test]
130130
fn commits_listing_cancellation_polls_atomic_flag() {
131131
use std::sync::atomic::Ordering;
132-
let dir = build_simple_repo(20);
132+
// 5 commits is enough to prove the walk got cut short: with the flag
133+
// pre-set, even one returned entry would still be `< 5`. The earlier
134+
// shape used 20 commits, which made the `build_simple_repo` shell-out
135+
// chain (~31 `git` calls) the dominant cost and pushed the test to
136+
// ~5 s warm / >8 s under `check.sh` parallel-check load (timing
137+
// confirmed in three back-to-back runs). The 8 s cap is intentional
138+
// (see `.config/nextest.toml`); trim the fixture instead.
139+
let dir = build_simple_repo(5);
133140
let (handle, root) = discover_repo(&dir).unwrap();
134141

135142
// Pre-set the cancel flag so the walk bails after 0 commits.
@@ -138,8 +145,8 @@ fn commits_listing_cancellation_polls_atomic_flag() {
138145
git_log::cancel_flag().store(false, Ordering::Relaxed);
139146

140147
assert!(
141-
entries.len() < 20,
142-
"cancellation should stop the walk before all 20 commits arrive"
148+
entries.len() < 5,
149+
"cancellation should stop the walk before all 5 commits arrive"
143150
);
144151
cleanup(&dir);
145152
}

apps/desktop/src-tauri/src/file_system/volume/in_memory_test.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,20 @@ async fn test_rename_nonexistent_source() {
335335
async fn test_concurrent_reads() {
336336
use std::sync::Arc;
337337

338+
// 10 concurrent tasks × 25 iterations each = 250 interleaved reads. The
339+
// earlier shape (100 iters, ~1 M entry materialisations across threads)
340+
// passed in ~2 s in isolation but timed out at 8 s under `check.sh`'s
341+
// parallel-check load — per `.config/nextest.toml` we trim the workload
342+
// rather than bump the cap. Concurrency races surface at much smaller
343+
// scale than this; 250 interleavings is plenty of pressure on the
344+
// `RwLock<HashMap>`.
338345
let volume = Arc::new(InMemoryVolume::with_file_count("Test", 1000));
339346
let mut handles = vec![];
340347

341-
// Spawn 10 tasks doing concurrent reads
342348
for _ in 0..10 {
343349
let vol = Arc::clone(&volume);
344350
handles.push(tokio::spawn(async move {
345-
for _ in 0..100 {
351+
for _ in 0..25 {
346352
let _ = vol.list_directory(Path::new(""), None).await;
347353
let _ = vol.exists(Path::new("/file_000001.txt")).await;
348354
let _ = vol.get_metadata(Path::new("/file_000010.txt")).await;

0 commit comments

Comments
 (0)