Skip to content

Commit 78a6a37

Browse files
committed
native(test): optional SMOKE_TEST env to auto-exit after N frames; add npm script native:smoke
1 parent 0610ed2 commit 78a6a37

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

crates/app-native/src/main.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ fn main() {
384384
pollster::block_on(GpuState::new(&window, Arc::clone(&shared_state))).expect("gpu");
385385
let _start = Instant::now();
386386

387+
let mut frames_left: Option<u32> = if std::env::var("SMOKE_TEST").ok().as_deref() == Some("1") {
388+
Some(120)
389+
} else {
390+
None
391+
};
392+
387393
event_loop
388394
.run(move |event, elwt| match event {
389395
Event::WindowEvent {
@@ -394,12 +400,23 @@ fn main() {
394400
event: WindowEvent::CloseRequested,
395401
..
396402
} => elwt.exit(),
397-
Event::AboutToWait => match state.render() {
398-
Ok(_) => state.window.request_redraw(),
399-
Err(wgpu::SurfaceError::Lost) => state.resize(state.window.inner_size()),
400-
Err(wgpu::SurfaceError::OutOfMemory) => elwt.exit(),
401-
Err(_) => {}
402-
},
403+
Event::AboutToWait => {
404+
match state.render() {
405+
Ok(_) => {
406+
state.window.request_redraw();
407+
if let Some(ref mut n) = frames_left {
408+
if *n == 0 {
409+
elwt.exit();
410+
} else {
411+
*n -= 1;
412+
}
413+
}
414+
}
415+
Err(wgpu::SurfaceError::Lost) => state.resize(state.window.inner_size()),
416+
Err(wgpu::SurfaceError::OutOfMemory) => elwt.exit(),
417+
Err(_) => {}
418+
}
419+
}
403420
_ => {}
404421
})
405422
.unwrap();

crates/app-web/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ struct GpuState<'a> {
906906
bind_group: wgpu::BindGroup,
907907
width: u32,
908908
height: u32,
909-
clear_color: wgpu::Color,
909+
clear_color: wgpu::Color,
910910
}
911911

912912
impl<'a> GpuState<'a> {
@@ -1111,7 +1111,6 @@ impl<'a> GpuState<'a> {
11111111
};
11121112
}
11131113

1114-
11151114
fn resize_if_needed(&mut self, width: u32, height: u32) {
11161115
if width == 0 || height == 0 {
11171116
return;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"ci:web": "npm run build:web && node server.js & SERVER_PID=$!; sleep 1; node web-test.js; kill $SERVER_PID",
1616
"build:native": "cargo build -p app-native",
1717
"native": "cargo run -p app-native",
18+
"native:smoke": "SMOKE_TEST=1 cargo run -p app-native",
1819
"build:all": "npm run build:native && npm run build:web",
1920
"clean": "cargo clean && rm -rf crates/app-web/pkg",
2021
"check:rust": "cargo fmt --all -- --check && cargo clippy --workspace --exclude app-web --all-targets -- -D warnings && cargo test --workspace --exclude app-web --all-targets && cargo build -p app-native",

web-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ const puppeteer = require("puppeteer");
156156
});
157157
if (!/Muted:\s*no/.test(hintMutedOff))
158158
throw new Error("hint Muted not no after M again");
159+
160+
// Click center to toggle mute on the hovered voice (expects a hit)
161+
await page.mouse.move(box.x, box.y);
162+
await page.mouse.click(box.x, box.y);
163+
await new Promise((r) => setTimeout(r, 120));
164+
if (!logs.some((l) => /\[click\] toggle mute voice \d+/.test(l)))
165+
throw new Error("missing toggle mute click log");
166+
167+
// Alt+Click to solo the same voice
168+
await page.keyboard.down("Alt");
169+
await page.mouse.click(box.x, box.y);
170+
await page.keyboard.up("Alt");
171+
await new Promise((r) => setTimeout(r, 120));
172+
if (!logs.some((l) => /\[click\] solo voice \d+/.test(l)))
173+
throw new Error("missing solo click log");
159174
} else {
160175
console.log(
161176
"[note] engine not started in CI (WebGPU unavailable); skipping R/Space/+/− assertions"

0 commit comments

Comments
 (0)