File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,13 @@ def test_coverage(test_fc_session_root_path, test_session_tmp_path):
81
81
exclude_region = "'mod tests {'"
82
82
target = "{}-unknown-linux-musl" .format (platform .machine ())
83
83
84
+ # Temporarily modify PATH so that "rustc" resolved to our wrapper script
85
+ # This is required as cargo kcov parses cargo's verbose output, and looking for lines starting with "Running `rustc":
86
+ # https://github.com/kennytm/cargo-kcov/blob/7a6bd499a1f9d4719a20cc9a37b6600fa1c9f68a/src/target_finder.rs#L44
87
+ # However, if we use the RUSTC_WRAPPER environment variable to make cargo run out script, the output will
88
+ # contain the lines "Running /firecracker/tests/rustc", and thus cargo kcov will fail to resolve the paths of the
89
+ # binaries compiled.
90
+ os .environ ["PATH" ] = "/firecracker/tests" + os .pathsep + os .environ ["PATH" ]
84
91
cmd = (
85
92
'CARGO_WRAPPER="kcov" RUSTFLAGS="{}" CARGO_TARGET_DIR={} '
86
93
"cargo kcov --all "
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # We have to fully qualify the path to rustc here, as we modified $PATH in a way that this script is founds before
4
+ # the actual rust executable.
5
+ # Then we invoke normal rustc, but force the 'link-dead-code' codegen option. This option is required for gathering
6
+ # coverage reports on proc-macros during cross-compilation, as the 'RUSTFLAGS' environment variable is ignored by cargo
7
+ # for build-scripts, plugins and proc-macros in this case.
8
+ # See also https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags
9
+ /usr/local/rust/bin/rustc $@ -Clink-dead-code
You can’t perform that action at this time.
0 commit comments