Skip to content

Commit

Permalink
Disable --remap-path-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Mar 1, 2022
1 parent d7112bb commit 20d5da7
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 51 deletions.
6 changes: 1 addition & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ fn set_env(cx: &Context, target: &mut impl EnvTarget) {
rustflags.push_str(" -C codegen-units=1");
}
}
// --remap-path-prefix is needed because sometimes macros are displayed with absolute path
rustflags.push_str(&format!(" --remap-path-prefix {}/=", cx.ws.metadata.workspace_root));
if !cx.cov.no_cfg_coverage {
rustflags.push_str(" --cfg coverage");
}
Expand Down Expand Up @@ -676,9 +674,7 @@ fn ignore_filename_regex(cx: &Context) -> Option<String> {
}
if !cx.cov.disable_default_ignore_filename_regex {
out.push(default_ignore_filename_regex());
for path in
[home::home_dir(), home::cargo_home().ok(), home::rustup_home().ok()].iter().flatten()
{
for path in [home::cargo_home().ok(), home::rustup_home().ok()].iter().flatten() {
out.push_abs_path(path);
}
for path in resolve_excluded_paths(cx) {
Expand Down
6 changes: 5 additions & 1 deletion tests/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ pub fn test_report(
cmd.args(["--color", "never", "--output-path"])
.arg(output_path)
.args(args)
.current_dir(workspace_root.path());
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!("--remap-path-prefix {}/=", fs::canonicalize(workspace_root.path())?.display()),
);
for (key, val) in envs {
cmd.env(key, val);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
1| 1|fn func(x: i32) -> bool {fn func(x: i32) -> bool {
2| 1| if x < 0 {
3| 0| true
3| 1| true
4| | } else {
5| 1| false
5| 0| false
6| | }
7| 1|}
8| |
9| 1|#[test]
10| 1|fn test() {
11| 1| #[cfg(a)]
12| 1| assert!(!func(1));
13| | #[cfg(not(a))]
14| | assert!(func(-1));
13| 1| #[cfg(not(a))]
14| 1| assert!(func(-1));
15| 1|}
12 changes: 6 additions & 6 deletions tests/fixtures/coverage-reports/cargo_config/cargo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"percent": 100.0
},
"lines": {
"count": 11,
"covered": 10,
"percent": 90.9090909090909
"count": 13,
"covered": 12,
"percent": 92.3076923076923
},
"regions": {
"count": 8,
Expand Down Expand Up @@ -53,9 +53,9 @@
"percent": 100
},
"lines": {
"count": 11,
"covered": 10,
"percent": 90.9090909090909
"count": 13,
"covered": 12,
"percent": 92.3076923076923
},
"regions": {
"count": 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FNF:4
FNH:4
BRF:0
BRH:0
LF:11
LH:10
LF:13
LH:12
end_of_record
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/lib.rs 8 1 87.50% 4 0 100.00% 11 1 90.91% 0 0 -
src/lib.rs 8 1 87.50% 4 0 100.00% 13 1 92.31% 0 0 -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 8 1 87.50% 4 0 100.00% 11 1 90.91% 0 0 -
TOTAL 8 1 87.50% 4 0 100.00% 13 1 92.31% 0 0 -
8 changes: 4 additions & 4 deletions tests/fixtures/coverage-reports/cargo_config/cargo_config.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
1| 1|fn func(x: i32) -> bool {fn func(x: i32) -> bool {
2| 1| if x < 0 {
3| 0| true
3| 1| true
4| | } else {
5| 1| false
5| 0| false
6| | }
7| 1|}
8| |
9| 1|#[test]
10| 1|fn test() {
11| 1| #[cfg(a)]
12| 1| assert!(!func(1));
13| | #[cfg(not(a))]
14| | assert!(func(-1));
13| 1| #[cfg(not(a))]
14| 1| assert!(func(-1));
15| 1|}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
1| 1|fn func(x: i32) -> bool {fn func(x: i32) -> bool {
2| 1| if x < 0 {
3| 0| true
3| 1| true
4| | } else {
5| 1| false
5| 0| false
6| | }
7| 1|}
8| |
9| 1|#[test]
10| 1|fn test() {
11| 1| #[cfg(a)]
12| 1| assert!(!func(1));
13| | #[cfg(not(a))]
14| | assert!(func(-1));
13| 1| #[cfg(not(a))]
14| 1| assert!(func(-1));
15| 1|}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"percent": 100.0
},
"lines": {
"count": 11,
"covered": 10,
"percent": 90.9090909090909
"count": 13,
"covered": 12,
"percent": 92.3076923076923
},
"regions": {
"count": 8,
Expand Down Expand Up @@ -53,9 +53,9 @@
"percent": 100
},
"lines": {
"count": 11,
"covered": 10,
"percent": 90.9090909090909
"count": 13,
"covered": 12,
"percent": 92.3076923076923
},
"regions": {
"count": 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FNF:4
FNH:4
BRF:0
BRH:0
LF:11
LH:10
LF:13
LH:12
end_of_record
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
src/lib.rs 8 1 87.50% 4 0 100.00% 11 1 90.91% 0 0 -
src/lib.rs 8 1 87.50% 4 0 100.00% 13 1 92.31% 0 0 -
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 8 1 87.50% 4 0 100.00% 11 1 90.91% 0 0 -
TOTAL 8 1 87.50% 4 0 100.00% 13 1 92.31% 0 0 -
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
1| 1|fn func(x: i32) -> bool {fn func(x: i32) -> bool {
2| 1| if x < 0 {
3| 0| true
3| 1| true
4| | } else {
5| 1| false
5| 0| false
6| | }
7| 1|}
8| |
9| 1|#[test]
10| 1|fn test() {
11| 1| #[cfg(a)]
12| 1| assert!(!func(1));
13| | #[cfg(not(a))]
14| | assert!(func(-1));
13| 1| #[cfg(not(a))]
14| 1| assert!(func(-1));
15| 1|}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
src/lib.rs:
/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpJWBy8h/src/lib.rs:
1| 1|mod module;mod module;
2| |pub use module::*;
3| |
4| 1|#[test]
5| 1|fn f() {}

src/module.rs:
/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpJWBy8h/src/module.rs:
1| 0|pub fn func(x: u32) {
2| 0| match x {
3| 0| 0 => {}
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/coverage-reports/no_test/link_dead_code.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"files": [
{
"filename": "src/lib.rs",
"filename": "/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpT4Wstw/src/lib.rs",
"summary": {
"branches": {
"count": 0,
Expand Down Expand Up @@ -35,7 +35,7 @@
}
},
{
"filename": "src/module.rs",
"filename": "/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpT4Wstw/src/module.rs",
"summary": {
"branches": {
"count": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
SF:src/lib.rs
SF:/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpjC2TwD/src/lib.rs
FNF:3
FNH:3
BRF:0
BRH:0
LF:3
LH:3
end_of_record
SF:src/module.rs
SF:/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpjC2TwD/src/module.rs
FNF:1
FNH:0
BRF:0
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/coverage-reports/no_test/link_dead_code.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
src/lib.rs:
/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpsGNoB8/src/lib.rs:
1| 1|mod module;mod module;
2| |pub use module::*;
3| |
4| 1|#[test]
5| 1|fn f() {}

src/module.rs:
/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpsGNoB8/src/module.rs:
1| 0|pub fn func(x: u32) {
2| 0| match x {
3| 0| 0 => {}
Expand Down
58 changes: 57 additions & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,37 @@ fn merge_with_failure_mode(output_dir: &Utf8Path, failure_mode_all: bool) {
cargo_llvm_cov()
.args(["--color", "never", "--no-report", "--features", "a"])
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();
cargo_llvm_cov()
.args(["--color", "never", "--no-report", "--features", "b"])
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();
let mut cmd = cargo_llvm_cov();
cmd.args(["--color", "never", "--no-run", "--output-path"])
.arg(output_path)
.args(args)
.current_dir(workspace_root.path());
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
);
cmd.assert_success();

if failure_mode_all {
Expand Down Expand Up @@ -191,12 +212,26 @@ fn clean_ws() {
cargo_llvm_cov()
.args(["--color", "never", "--no-report", "--features", "a"])
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();
cargo_llvm_cov()
.args(["--color", "never", "--no-run", "--output-path"])
.arg(output_path)
.args(args)
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();

normalize_output(output_path, args).unwrap();
Expand All @@ -205,16 +240,37 @@ fn clean_ws() {
cargo_llvm_cov()
.args(["clean", "--color", "never", "--workspace"])
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();
cargo_llvm_cov()
.args(["--color", "never", "--no-report", "--features", "a"])
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();
cargo_llvm_cov()
.args(["--color", "never", "--no-run", "--output-path"])
.arg(output_path)
.args(args)
.current_dir(workspace_root.path())
.env(
"RUSTFLAGS",
format!(
"--remap-path-prefix {}/=",
fs::canonicalize(workspace_root.path()).unwrap().display()
),
)
.assert_success();

normalize_output(output_path, args).unwrap();
Expand Down

0 comments on commit 20d5da7

Please sign in to comment.