Skip to content

Commit

Permalink
Copy port from headless test server when using WASM_BINDGEN_TEST_ADDR…
Browse files Browse the repository at this point in the history
…ESS (#3873)
  • Loading branch information
lynn authored Mar 6, 2024
1 parent f0f3a47 commit ac462d5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# `wasm-bindgen` Change Log
--------------------------------------------------------------------------------

## Unreleased

### Fixed

* Copy port from headless test server when using `WASM_BINDGEN_TEST_ADDRESS`.
[#3873](https://github.com/rustwasm/wasm-bindgen/pull/3873)

## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92)

Released 2024-03-04
Expand Down Expand Up @@ -249,7 +256,7 @@ Released 2023-11-01
It was also automatically changed for `IdbFileHandle`, which is deprecated.
[#3537](https://github.com/rustwasm/wasm-bindgen/pull/3537)

* Changed behavior when compiling to `wasm32-wasi` to match `wasm32-emscripten` and
* Changed behavior when compiling to `wasm32-wasi` to match `wasm32-emscripten` and
non-WASM targets, generating a stub that panics when called rather than a wasm-
bindgen placeholder.
[#3233](https://github.com/rustwasm/wasm-bindgen/pull/3233)
Expand Down
19 changes: 0 additions & 19 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,25 +1768,6 @@ impl<'a> Context<'a> {
self.memview("Float64", memory)
}

fn memview_function(&mut self, t: VectorKind, memory: MemoryId) -> MemView {
match t {
VectorKind::String => self.expose_uint8_memory(memory),
VectorKind::I8 => self.expose_int8_memory(memory),
VectorKind::U8 => self.expose_uint8_memory(memory),
VectorKind::ClampedU8 => self.expose_clamped_uint8_memory(memory),
VectorKind::I16 => self.expose_int16_memory(memory),
VectorKind::U16 => self.expose_uint16_memory(memory),
VectorKind::I32 => self.expose_int32_memory(memory),
VectorKind::U32 => self.expose_uint32_memory(memory),
VectorKind::I64 => self.expose_int64_memory(memory),
VectorKind::U64 => self.expose_uint64_memory(memory),
VectorKind::F32 => self.expose_f32_memory(memory),
VectorKind::F64 => self.expose_f64_memory(memory),
VectorKind::Externref => self.expose_uint32_memory(memory),
VectorKind::NamedExternref(_) => self.expose_uint32_memory(memory),
}
}

fn memview(&mut self, kind: &'static str, memory: walrus::MemoryId) -> MemView {
let view = self.memview_memory(kind, memory);
if !self.should_write_global(view.name.clone()) {
Expand Down
16 changes: 14 additions & 2 deletions crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,20 @@ pub fn run(server: &SocketAddr, shell: &Shell, timeout: u64) -> Result<(), Error

// Visit our local server to open up the page that runs tests, and then get
// some handles to objects on the page which we'll be scraping output from.
let url =
std::env::var("WASM_BINDGEN_TEST_ADDRESS").unwrap_or_else(|_| format!("http://{}", server));
//
// If WASM_BINDGEN_TEST_ADDRESS is set, use it as the local server URL,
// trying to inherit the port from the server if it isn't specified.
let url = match std::env::var("WASM_BINDGEN_TEST_ADDRESS") {
Ok(u) => {
let mut url = Url::parse(&u)?;
if url.port().is_none() {
url.set_port(Some(server.port())).unwrap();
}
url.to_string()
}
Err(_) => format!("http://{}", server),
};

shell.status(&format!("Visiting {}...", url));
client.goto(&id, &url)?;
shell.status("Loading page elements...");
Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/bin/wasm-bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct Args {
flag_no_modules_global: Option<String>,
flag_remove_name_section: bool,
flag_remove_producers_section: bool,
#[allow(dead_code)]
flag_weak_refs: Option<bool>,
flag_reference_types: Option<bool>,
flag_keep_lld_exports: bool,
Expand Down

0 comments on commit ac462d5

Please sign in to comment.