Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-pack test appears to ignore [profile.test] in Cargo.toml in procedural macro invocations #1173

Open
skondrashov opened this issue Sep 8, 2022 · 0 comments

Comments

@skondrashov
Copy link

skondrashov commented Sep 8, 2022

🐛 Bug description

In a procedural macro crate, using a decorator like #[cfg(debug_assertions)] in the macro and [profile.test] in Cargo.toml to modify the configuration appears to result in the configuration being ignored by wasm-pack test, but not by cargo test. When I originally opened this I did not realize what was going on and that it's specific to the procedural macro use case, so this might be very limited to what I am doing. To be honest I still don't really understand what's going on. On writing out steps to reproduce, I'm thinking that wasm-pack test builds twice, and I guess the first time doesn't use the test profile, and that the extra output I see is a result of that. cargo test only builds the test target, so I don't see any output I'm not expecting. I guess this can be closed, or linked as support for not building twice in tests, if there's any discussion on that? I can work around this with --release for my use case.

🤔 Expected Behavior

I am expecting wasm-pack test --headless --firefox to build/run my tests and use the test profile to configure the build, including at the time that the procedural macro is run.

👟 Steps to reproduce

lib.rs:

extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro]
pub fn test_setup(input: TokenStream) -> TokenStream {
    #[cfg(debug_assertions)]
    println!("1\n");
    println!("2\n");
    input
}

tests/test.rs:

extern crate wacky;
extern crate wasm_bindgen_test;

use self::{wacky::test_setup, wasm_bindgen_test::*};

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
fn test() {
    test_setup! {}
}

Cargo.toml:

[package]
edition = "2021"
name = "wacky"
version = "0.1.0"

[lib]
proc-macro = true

[dependencies]
wasm-bindgen-test = "^0.3.32"

[profile.test]
debug-assertions = false

With this setup, wasm-pack test --headless --firefox prints "1" and "2" and then "2" again. cargo test just prints "2", as I would expect.

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.10.3
rustc version: 1.63.0 (4b91a6ea7 2022-08-08)

@skondrashov skondrashov changed the title wasm-pack test ignores [profile.test] in Cargo.toml wasm-pack test appears to ignore [profile.test] in Cargo.toml in procedural macro invocations Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant