xd009642 / tarpaulin

A code coverage tool for Rust projects
https://crates.io/crates/cargo-tarpaulin
Apache License 2.0
2.5k stars 180 forks source link

Multiple target coverage #703

Closed MarcAntoine-Arnaud closed 3 years ago

MarcAntoine-Arnaud commented 3 years ago

Describe the feature In our projets, libraries are compatible with WebAssembly and not. Some specific code is required to be mentioned using #[cfg(not(target_arch = "wasm32"))] and #[cfg(target_arch = "wasm32")].

Tarpaulin will generate 1 coverage for 1 target. Is it possible to merge 2 results of tarpaulin generated with 2 different build target ?

Thank you, Marc-Antoine

xd009642 commented 3 years ago

Yes you can use the config files. It's described in the readme but roughly speaking create something like a tarpaulin.toml in the project root and:

[wasm]
target = "whatever-the-target-is"

[non_wasm]
target = "x64-linux-gnu" // Or whatever the target is

[report]  // Then in a report settings set anything you want for reporting the merged coverage results
coveralls = "coveralls_key"
out = ["Html", "Xml"]

I think I also accept .tarpaulin.toml if you want it as a hidden file. If you check the readme and let me know if anything is unclear

MarcAntoine-Arnaud commented 3 years ago

Hello,

Thank for instructions and sorry for the long delay of my response. I have tester with:

# to add wasm target on the current toolchain
rustup target add wasm32-unknown-unknown
[wasm32]
target = "wasm32-unknown-unknown"

[linux_x86_64]
target = "x86_64-unknown-linux-gnu"

[report]
out = ["Xml"]

but I got these errors:

Apr 23 09:31:44.941 ERROR cargo_tarpaulin: Tarpaulin experienced an internal error
Apr 23 09:31:44.954 ERROR cargo_tarpaulin: Failed to get test coverage! Error: Error while parsing

Does Tarpaulin support Wasm ? as it supports mostly only linux ... (it's an another issue/feature)