Skip to content

Commit e021ba4

Browse files
authored
Add WASM_BINDGEN_TEST_DRIVER_TIMEOUT (#4320)
1 parent 14acd7d commit e021ba4

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

CHANGELOG.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55

66
### Added
77

8+
* Add clear error message to communicate new feature resolver version requirements.
9+
[#4312](https://github.com/rustwasm/wasm-bindgen/pull/4312)
10+
811
* Add support for multi-threading in Node.js.
912
[#4318](https://github.com/rustwasm/wasm-bindgen/pull/4318)
1013

11-
* Add clear error message to communicate new feature resolver version requirements.
12-
[#4312](https://github.com/rustwasm/wasm-bindgen/pull/4312)
14+
* Add `WASM_BINDGEN_TEST_DRIVER_TIMEOUT` environment variable to control the timeout to start and connect to the test driver.
15+
[#4320](https://github.com/rustwasm/wasm-bindgen/pull/4320)
16+
17+
### Changed
1318

1419
* Remove `once_cell/critical-section` requirement for `no_std` with atomics.
1520
[#4322](https://github.com/rustwasm/wasm-bindgen/pull/4322)
1621

17-
### Changed
18-
1922
* `static FOO: Option<T>` now returns `None` if undeclared in JS instead of throwing an error in JS.
2023
[#4319](https://github.com/rustwasm/wasm-bindgen/pull/4319)
2124

crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ pub struct LegacyNewSessionParameters {
5555
/// binary, controlling it, running tests, scraping output, displaying output,
5656
/// etc. It will return `Ok` if all tests finish successfully, and otherwise it
5757
/// will return an error if some tests failed.
58-
pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error> {
58+
pub fn run(
59+
server: &SocketAddr,
60+
shell: &Shell,
61+
driver_timeout: u64,
62+
test_timeout: u64,
63+
) -> Result<(), Error> {
5964
let driver = Driver::find()?;
6065
let mut drop_log: Box<dyn FnMut()> = Box::new(|| ());
6166
let driver_url = match driver.location() {
@@ -64,7 +69,7 @@ pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error
6469
// Wait for the driver to come online and bind its port before we try to
6570
// connect to it.
6671
let start = Instant::now();
67-
let max = Duration::new(5, 0);
72+
let max = Duration::new(driver_timeout, 0);
6873

6974
let (driver_addr, mut child) = 'outer: loop {
7075
// Allow tests to run in parallel (in theory) by finding any open port
@@ -173,7 +178,7 @@ pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error
173178
// information.
174179
shell.status("Waiting for test to finish...");
175180
let start = Instant::now();
176-
let max = Duration::new(timeout, 0);
181+
let max = Duration::new(test_timeout, 0);
177182
while start.elapsed() < max {
178183
if client.text(&id, &output)?.contains("test result: ") {
179184
break;

crates/cli/src/bin/wasm-bindgen-test-runner/main.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,15 @@ fn main() -> anyhow::Result<()> {
214214
return Ok(());
215215
}
216216

217-
let timeout = env::var("WASM_BINDGEN_TEST_TIMEOUT")
217+
let driver_timeout = env::var("WASM_BINDGEN_TEST_DRIVER_TIMEOUT")
218+
.map(|timeout| {
219+
timeout
220+
.parse()
221+
.expect("Could not parse 'WASM_BINDGEN_TEST_DRIVER_TIMEOUT'")
222+
})
223+
.unwrap_or(5);
224+
225+
let browser_timeout = env::var("WASM_BINDGEN_TEST_TIMEOUT")
218226
.map(|timeout| {
219227
timeout
220228
.parse()
@@ -223,7 +231,7 @@ fn main() -> anyhow::Result<()> {
223231
.unwrap_or(20);
224232

225233
if debug {
226-
println!("Set timeout to {} seconds...", timeout);
234+
println!("Set timeout to {} seconds...", browser_timeout);
227235
}
228236

229237
// Make the generated bindings available for the tests to execute against.
@@ -307,7 +315,7 @@ fn main() -> anyhow::Result<()> {
307315
}
308316

309317
thread::spawn(|| srv.run());
310-
headless::run(&addr, &shell, timeout)?;
318+
headless::run(&addr, &shell, driver_timeout, browser_timeout)?;
311319
}
312320
}
313321
Ok(())

0 commit comments

Comments
 (0)