Skip to content

Commit

Permalink
Add WASM_BINDGEN_TEST_DRIVER_TIMEOUT (#4320)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Dec 6, 2024
1 parent 14acd7d commit e021ba4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@

### Added

* Add clear error message to communicate new feature resolver version requirements.
[#4312](https://github.com/rustwasm/wasm-bindgen/pull/4312)

* Add support for multi-threading in Node.js.
[#4318](https://github.com/rustwasm/wasm-bindgen/pull/4318)

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

### Changed

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

### Changed

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

Expand Down
11 changes: 8 additions & 3 deletions crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ pub struct LegacyNewSessionParameters {
/// binary, controlling it, running tests, scraping output, displaying output,
/// etc. It will return `Ok` if all tests finish successfully, and otherwise it
/// will return an error if some tests failed.
pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error> {
pub fn run(
server: &SocketAddr,
shell: &Shell,
driver_timeout: u64,
test_timeout: u64,
) -> Result<(), Error> {
let driver = Driver::find()?;
let mut drop_log: Box<dyn FnMut()> = Box::new(|| ());
let driver_url = match driver.location() {
Expand All @@ -64,7 +69,7 @@ pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error
// Wait for the driver to come online and bind its port before we try to
// connect to it.
let start = Instant::now();
let max = Duration::new(5, 0);
let max = Duration::new(driver_timeout, 0);

let (driver_addr, mut child) = 'outer: loop {
// Allow tests to run in parallel (in theory) by finding any open port
Expand Down Expand Up @@ -173,7 +178,7 @@ pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error
// information.
shell.status("Waiting for test to finish...");
let start = Instant::now();
let max = Duration::new(timeout, 0);
let max = Duration::new(test_timeout, 0);
while start.elapsed() < max {
if client.text(&id, &output)?.contains("test result: ") {
break;
Expand Down
14 changes: 11 additions & 3 deletions crates/cli/src/bin/wasm-bindgen-test-runner/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,15 @@ fn main() -> anyhow::Result<()> {
return Ok(());
}

let timeout = env::var("WASM_BINDGEN_TEST_TIMEOUT")
let driver_timeout = env::var("WASM_BINDGEN_TEST_DRIVER_TIMEOUT")
.map(|timeout| {
timeout
.parse()
.expect("Could not parse 'WASM_BINDGEN_TEST_DRIVER_TIMEOUT'")
})
.unwrap_or(5);

let browser_timeout = env::var("WASM_BINDGEN_TEST_TIMEOUT")
.map(|timeout| {
timeout
.parse()
Expand All @@ -223,7 +231,7 @@ fn main() -> anyhow::Result<()> {
.unwrap_or(20);

if debug {
println!("Set timeout to {} seconds...", timeout);
println!("Set timeout to {} seconds...", browser_timeout);
}

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

thread::spawn(|| srv.run());
headless::run(&addr, &shell, timeout)?;
headless::run(&addr, &shell, driver_timeout, browser_timeout)?;
}
}
Ok(())
Expand Down

0 comments on commit e021ba4

Please sign in to comment.