Tarpaulin: Feature: proper .cargo/config support

Created on 12 Aug 2020  ยท  5Comments  ยท  Source: xd009642/tarpaulin

Trying to run simd-json.rs tests with tarpaulin fails with the error: Failed to compile tests! Error: mismatched types

The tests run otherwise fine, adding --verbose doesn't give any additional information :(

โฏ cargo tarpaulin --verbose
[INFO tarpaulin] Creating config
[INFO tarpaulin] Running Tarpaulin
[INFO tarpaulin] Building project
   Compiling simd-json v0.3.16 (/home/heinz/Projects/simd-lite/simd-json)
error: could not compile `simd-json`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
[ERROR tarpaulin] Failed to compile tests! Error: mismatched types
Error: "Failed to compile tests! Error: mismatched types"
enhancement help wanted

Most helpful comment

I've changed the title of this issue, and I'll put some description here for what I plan on being the solution.

So using the documentation here https://doc.rust-lang.org/cargo/reference/config.html merge the rustflags so they'd be the same as if you ran cargo test plus tarpaulins options. This means:

  • Parsing the hierarchy at the top of the docs for the different configs in different workspaces
  • Handling both config and config.toml named files
  • Merge them handling any conflicts in the flags and logging warnings for such conflicts

All the code should be fine in the src/cargo.rs file, around the bottom there's some existing code to work out the rust flags which is what needs to be changed.

All 5 comments

--debug might give more information as it also puts cargo on max verbosity, I can have a proper look when I finish work today

Thanks! --debug gives a bit more output :) managed to dig into it and find the issue. the .cargo/config seems to get ignored when run with cargo tarpaulin that lead to simd-json.rs erroring (it enforces AVX2 support).

I am fine with closing this as it's resolved OTOH it might be wroth to document that behaviour, or warn if a .cargo/config is detected?

I'm not sure why it would get ignored given I call off to cargo, maybe the RUSTFLAGS I set? Either way I'd like to try and get tarpaulin to play nicely with .cargo/config, but yeah failing that documentation and a warning will be done :+1:

That might be, the .cargo/config for simd-json.rs sets RUSTFLAGS to use native cpu support :) that would explain it. Interestingly setting RUSTFLAGS in the env works

I've changed the title of this issue, and I'll put some description here for what I plan on being the solution.

So using the documentation here https://doc.rust-lang.org/cargo/reference/config.html merge the rustflags so they'd be the same as if you ran cargo test plus tarpaulins options. This means:

  • Parsing the hierarchy at the top of the docs for the different configs in different workspaces
  • Handling both config and config.toml named files
  • Merge them handling any conflicts in the flags and logging warnings for such conflicts

All the code should be fine in the src/cargo.rs file, around the bottom there's some existing code to work out the rust flags which is what needs to be changed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xd009642 picture xd009642  ยท  9Comments

paulvt picture paulvt  ยท  5Comments

Ch00k picture Ch00k  ยท  5Comments

Aeradriel picture Aeradriel  ยท  8Comments

stanislav-tkach picture stanislav-tkach  ยท  5Comments