Skip to content

Commit

Permalink
test: fix replacing .exe only once
Browse files Browse the repository at this point in the history
On non-Windows platform the redacted string became something like below,
which was valid but didn't make sense:

```
[EXE]/[EXE]U[EXE]s[EXE]e[EXE]r[EXE]s[EXE]/[EXE]w[EXE]h[EXE]l[EXE]o[EXE]/[EXE]d[EXE]e[EXE]v[EXE]/[EXE]r[EXE]u[EXE]s[EXE]t[EXE]/[EXE]b[EXE]u[EXE]i[EXE]l[EXE]d[EXE]/[EXE]a[EXE]a[EXE]r[EXE]c[EXE]h[EXE]6[EXE]4[EXE]-[EXE]a[EXE]p[EXE]p[EXE]l[EXE]e[EXE]-[EXE]d[EXE]a[EXE]r[EXE]w[EXE]i[EXE]n[EXE]/[EXE]s[EXE]t[EXE]a[EXE]g[EXE]e[EXE]2[EXE]-[EXE]t[EXE]o[EXE]o[EXE]l[EXE]s[EXE]/[EXE]a[EXE]a[EXE]r[EXE]c[EXE]h[EXE]6[EXE]4[EXE]-[EXE]a[EXE]p[EXE]p[EXE]l[EXE]e[EXE]-[EXE]d[EXE]a[EXE]r[EXE]w[EXE]i[EXE]n[EXE]/[EXE]r[EXE]e[EXE]l[EXE]e[EXE]a[EXE]s[EXE]e[EXE]/[EXE]c[EXE]a[EXE]r[EXE]g[EXE]o[EXE]
```

Here we simply remove the extension and append `[EXE]` at the end.
  • Loading branch information
weihanglo committed Nov 9, 2024
1 parent d8cb5fb commit c03c580
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3888,12 +3888,15 @@ fn cargo_test_env() {
.file("src/lib.rs", &src)
.build();

let cargo = cargo_exe()
.canonicalize()
.unwrap()
.to_str()
.unwrap()
.replace(std::env::consts::EXE_SUFFIX, "[EXE]");
let cargo = format!(
"{}[EXE]",
cargo_exe()
.canonicalize()
.unwrap()
.with_extension("")
.to_str()
.unwrap()
);
p.cargo("test --lib -- --nocapture")
.with_stderr_contains(cargo)
.with_stdout_data(str![[r#"
Expand All @@ -3908,10 +3911,7 @@ test env_test ... ok
.unwrap()
.canonicalize()
.unwrap();
let stderr_rustc = rustc
.to_str()
.unwrap()
.replace(std::env::consts::EXE_SUFFIX, "[EXE]");
let stderr_rustc = format!("{}[EXE]", rustc.with_extension("").to_str().unwrap());
p.cargo("test --lib -- --nocapture")
// we use rustc since $CARGO is only used if it points to a path that exists
.env(cargo::CARGO_ENV, rustc)
Expand Down

0 comments on commit c03c580

Please sign in to comment.