Skip to content

Commit ea96140

Browse files
committed
test: windows-portable fixtures; witness decoupled to its own workflow
- stale-lock fixture: a spawned-and-reaped child supplies the dead PID; PID 0 reads alive on Windows (System Idle Process) - workspace_root fixture writes through toml serialization; a raw Windows path in a hand-formatted basic string parses as escape sequences - facade walk and callee asserts compare PathBuf components; display-string compares carry separator assumptions - profiles orchestrator test module gated cfg(all(test, unix)); its failure fixture is unix permission bits - windows witness runs standalone in windows-witness.yml (dispatch + nightly cron + workflow_call); full-test waits only on gates - witness failures emit a ::warning annotation and the job exits zero; red is reserved for gates; gate promotion removes the || echo fallback and re-includes via uses:
1 parent a8d6327 commit ea96140

6 files changed

Lines changed: 94 additions & 51 deletions

File tree

‎.github/workflows/full-test.yml‎

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,9 @@ jobs:
6767
env:
6868
RUSTDOCFLAGS: -D warnings
6969

70-
# Windows witness leg: the watcher's event-kind assumptions are
71-
# platform-backend-specific (FSEvents vs inotify vs
72-
# ReadDirectoryChangesW), and Windows has no local container gate.
73-
# Non-blocking until its first sustained green, then promote by
74-
# removing continue-on-error.
75-
test-windows:
76-
name: Full Test Suite (windows witness)
77-
runs-on: windows-latest
78-
continue-on-error: true
79-
timeout-minutes: 40
80-
steps:
81-
- uses: actions/checkout@v6
82-
83-
- name: Install Rust toolchain
84-
uses: dtolnay/rust-toolchain@stable
85-
86-
- name: Cache cargo artifacts
87-
uses: Swatinem/rust-cache@v2
88-
with:
89-
cache-on-failure: true
90-
91-
- name: Run tests
92-
run: cargo test --verbose
70+
# Windows runs in windows-witness.yml (dispatch + nightly), decoupled
71+
# so this chain waits only on gates. It rejoins here as a
72+
# `uses:` job (workflow_call) when promoted to a gate.
9373

9474
# Release build and size check -- only on version tags
9575
release-check:
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Windows witness leg: the watcher's event-kind assumptions are
2+
# platform-backend-specific (FSEvents vs inotify vs
3+
# ReadDirectoryChangesW), and Windows has no local container gate.
4+
# WITNESS, not gate: failures surface as warning annotations and the
5+
# job stays green -- red is reserved for gates. Promote to a gate by
6+
# removing the `|| echo` fallback once Windows is sustained-green,
7+
# then re-include in full-test.yml as a `uses:` job (workflow_call).
8+
name: Windows Witness
9+
on:
10+
# Iteration loop during the Windows arc
11+
workflow_dispatch:
12+
13+
# Sustained-green record accumulates without a dispatch
14+
schedule:
15+
- cron: '0 0 * * *' # Midnight UTC daily
16+
17+
# Chain include for gate promotion
18+
workflow_call:
19+
20+
env:
21+
CARGO_TERM_COLOR: always
22+
RUST_BACKTRACE: 1
23+
24+
jobs:
25+
test-windows:
26+
name: windows witness
27+
runs-on: windows-latest
28+
timeout-minutes: 40
29+
steps:
30+
- uses: actions/checkout@v6
31+
32+
- name: Install Rust toolchain
33+
uses: dtolnay/rust-toolchain@stable
34+
35+
- name: Cache cargo artifacts
36+
uses: Swatinem/rust-cache@v2
37+
with:
38+
cache-on-failure: true
39+
40+
- name: Run tests (witness)
41+
shell: bash
42+
run: |
43+
cargo test --verbose || echo "::warning title=Windows witness::test failures on Windows (witness leg, non-blocking) -- see this job's log; tracked in the wiki's Windows stories"

‎src/cli/commands/serve.rs‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,23 @@ mod serve_lock_tests {
562562
let dir = TempDir::new().unwrap();
563563
let lock_path = dir.path().join("serve.lock");
564564

565-
// PID 0 never refers to a normal process on Unix; sysinfo also reports
566-
// it as absent. Use it as a synthetic stale entry.
567-
std::fs::write(&lock_path, "0").unwrap();
568-
assert!(!pid_is_alive(0), "PID 0 must read as dead for this test");
565+
// A reaped child is dead on every platform. PID 0 is not: it reads
566+
// alive on Windows (System Idle Process).
567+
#[cfg(unix)]
568+
let mut child = std::process::Command::new("true").spawn().unwrap();
569+
#[cfg(windows)]
570+
let mut child = std::process::Command::new("cmd")
571+
.args(["/C", "exit"])
572+
.spawn()
573+
.unwrap();
574+
let dead_pid = child.id();
575+
child.wait().unwrap();
576+
577+
std::fs::write(&lock_path, dead_pid.to_string()).unwrap();
578+
assert!(
579+
!pid_is_alive(dead_pid),
580+
"reaped child must read as dead for this test"
581+
);
569582

570583
let guard = ServeLockGuard::acquire(dir.path()).expect("stale lock should be reclaimed");
571584
let contents = std::fs::read_to_string(&lock_path).unwrap();

‎src/config/mod.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,16 @@ enabled = false
671671
let gone = temp_dir.path().join("no-such-dir");
672672

673673
let config_path = temp_dir.path().join("settings.toml");
674+
// Serialize instead of hand-formatting: a raw Windows path in a TOML
675+
// basic string parses `\U` as a unicode escape and errors the load.
676+
let mut table = toml::value::Table::new();
677+
table.insert(
678+
"workspace_root".into(),
679+
toml::Value::String(gone.display().to_string()),
680+
);
674681
fs::write(
675682
&config_path,
676-
format!("workspace_root = \"{}\"\n", gone.display()),
683+
toml::to_string(&toml::Value::Table(table)).unwrap(),
677684
)
678685
.unwrap();
679686

‎src/indexing/facade.rs‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,7 +2404,8 @@ mod tests {
24042404
);
24052405
let path = facade.get_file_path(callees[0].file_id).unwrap_or_default();
24062406
assert!(
2407-
callees[0].name.as_ref() == "helper" && path.ends_with("z/Base.java"),
2407+
callees[0].name.as_ref() == "helper"
2408+
&& std::path::Path::new(&path).ends_with("z/Base.java"),
24082409
"must resolve to the inherited parent's member, not the decoy \
24092410
(force={force}), got: {picked:?}"
24102411
);
@@ -3404,40 +3405,40 @@ mod tests {
34043405
let facade = IndexFacade::new(std::sync::Arc::new(settings)).unwrap();
34053406

34063407
let canonical_root = root.canonicalize().unwrap();
3407-
let names = |scope: &std::path::Path| -> Vec<String> {
3408-
let mut v: Vec<String> = facade
3408+
// Compare PathBufs, not display strings: component-wise equality is
3409+
// separator-agnostic where a `/`-joined string compare is not.
3410+
let names = |scope: &std::path::Path| -> Vec<std::path::PathBuf> {
3411+
let mut v: Vec<std::path::PathBuf> = facade
34093412
.discoverable_files(scope)
34103413
.into_iter()
3411-
.map(|p| {
3412-
p.strip_prefix(&canonical_root)
3413-
.unwrap()
3414-
.to_string_lossy()
3415-
.into_owned()
3416-
})
3414+
.map(|p| p.strip_prefix(&canonical_root).unwrap().to_path_buf())
34173415
.collect();
34183416
v.sort();
34193417
v
34203418
};
34213419

34223420
assert_eq!(
34233421
names(&root),
3424-
vec!["pkg/a.py", "pkg/newmod/e.py"],
3422+
vec![
3423+
std::path::PathBuf::from("pkg/a.py"),
3424+
std::path::PathBuf::from("pkg/newmod/e.py")
3425+
],
34253426
"root scope: ignore chains, dot-files, and extensions filter"
34263427
);
34273428
assert_eq!(
34283429
names(&pkg.join("newmod")),
3429-
vec!["pkg/newmod/e.py"],
3430+
vec![std::path::PathBuf::from("pkg/newmod/e.py")],
34303431
"subtree scope restricts to the subtree"
34313432
);
34323433
assert_eq!(
34333434
names(&pkg.join("generated")),
3434-
Vec::<String>::new(),
3435+
Vec::<std::path::PathBuf>::new(),
34353436
"a scope inside an ignored directory is empty because the \
34363437
chain anchors at the registered root"
34373438
);
34383439
assert_eq!(
34393440
names(&dir.path().join("outside")),
3440-
Vec::<String>::new(),
3441+
Vec::<std::path::PathBuf>::new(),
34413442
"a scope outside every registered root is empty"
34423443
);
34433444
}
@@ -3465,20 +3466,18 @@ mod tests {
34653466
let facade = IndexFacade::new(std::sync::Arc::new(settings)).unwrap();
34663467
let canonical_root = root.canonicalize().unwrap();
34673468

3468-
let mut dirs: Vec<String> = facade
3469+
let mut dirs: Vec<std::path::PathBuf> = facade
34693470
.discoverable_dirs(&root.join("newmod"))
34703471
.into_iter()
3471-
.map(|p| {
3472-
p.strip_prefix(&canonical_root)
3473-
.unwrap()
3474-
.to_string_lossy()
3475-
.into_owned()
3476-
})
3472+
.map(|p| p.strip_prefix(&canonical_root).unwrap().to_path_buf())
34773473
.collect();
34783474
dirs.sort();
34793475
assert_eq!(
34803476
dirs,
3481-
vec!["newmod", "newmod/empty_sub"],
3477+
vec![
3478+
std::path::PathBuf::from("newmod"),
3479+
std::path::PathBuf::from("newmod/empty_sub")
3480+
],
34823481
"empty dirs watched, ignored subtree pruned by the root-anchored chain"
34833482
);
34843483
}

‎src/profiles/orchestrator.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,16 @@ fn current_timestamp() -> String {
240240
format!("{years:04}-{month:02}-{day:02}T{hours:02}:{minutes:02}:{seconds:02}Z")
241241
}
242242

243-
#[cfg(test)]
243+
// The module's one test forces the save failure via unix permission bits;
244+
// on Windows the module would compile to an unused import.
245+
#[cfg(all(test, unix))]
244246
mod tests {
245247
use super::*;
246248

247249
// Regression: profiles.json save failure (step 8) must roll back the
248250
// persisted lockfile and surface the error instead of swallowing the
249251
// rollback outcome.
250252
#[test]
251-
#[cfg(unix)]
252253
fn profiles_config_save_failure_rolls_back_lockfile() {
253254
use std::os::unix::fs::PermissionsExt;
254255

0 commit comments

Comments
 (0)