Skip to content

Structs whose name begins with "Test" cause run-time failures in wasm-bindgen-test tests #2121

@prestwich

Description

@prestwich

Describe the Bug

When using wasm-bindgen-test via wasm-pack test, if any struct have a name beginning with Test or test and have the #[wasm-bindgen] macro the tests will fail to run.

Steps to Reproduce

  1. wasm-bindgen = "0.2.62"
  2. wasm-bindgen-test = "0.3.12"
  3. Add the following to a fresth lib.rs and run wasm-pack test --node.
#[wasm_bindgen]
pub struct Test;

#[cfg(test)]
pub mod test {
    use wasm_bindgen_test::*;

    #[wasm_bindgen_test]
    fn pass() {
        assert_eq!(1, 1);
    }
}

Actual Behavior

These struct names work:

  • ConnectionTest
  • SocketTest
  • ATest
  • Attestation

These names fail:

  • Test
  • TestConnection
  • Testnet
  • Testify
  • test
  • testify

Removing the #[wasm-bindgen] macro causes everything to succeed. Packages can be built succesfully, imported into Node, and used normally. Only tests break

Failures produce the following error message (stack information has been trimmed):

$ wasm-pack test --node

panicked at 'exception thrown while creating a test: Error: recursive use of an object detected which would lead to unsafe aliasing in rust

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions