Skip to content

Commit

Permalink
Switch to case-sensitive environment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Feb 6, 2020
1 parent 3489428 commit 499f917
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ fn build_base_args<'a, 'cfg>(
let exe_path = cx
.files()
.bin_link_for_target(bin_target, unit.kind, cx.bcx)?;
let key = format!("CARGO_BIN_EXE_{}", bin_target.crate_name().to_uppercase());
let key = format!("CARGO_BIN_EXE_{}", bin_target.name());
cmd.env(&key, exe_path);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/doc/src/reference/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ let version = env!("CARGO_PKG_VERSION");
* `CARGO_BIN_EXE_<name>` — The absolute path to a binary target's executable.
This is only set when building an [integration test] or benchmark. This may
be used with the [`env` macro] to find the executable to run for testing
purposes. The `<name>` is the name of the binary converted to uppercase, and
`-` converted to `_`. Binaries are automatically built when the test is
built, unless the binary has required features that are not enabled.
purposes. The `<name>` is the name of the binary target, exactly as-is. For
example, `CARGO_BIN_EXE_my-program` for a binary named `my-program`.
Binaries are automatically built when the test is built, unless the binary
has required features that are not enabled.

[integration test]: manifest.md#integration-tests
[`env` macro]: ../../std/macro.env.html
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4029,9 +4029,9 @@ fn bin_env_for_test() {
&r#"
#[test]
fn run_bins() {
assert_eq!(env!("CARGO_BIN_EXE_FOO"), "<FOO_PATH>");
assert_eq!(env!("CARGO_BIN_EXE_WITH_DASH"), "<WITH_DASH_PATH>");
assert_eq!(env!("CARGO_BIN_EXE_GRÜSSEN"), "<GRÜSSEN_PATH>");
assert_eq!(env!("CARGO_BIN_EXE_foo"), "<FOO_PATH>");
assert_eq!(env!("CARGO_BIN_EXE_with-dash"), "<WITH_DASH_PATH>");
assert_eq!(env!("CARGO_BIN_EXE_grüßen"), "<GRÜSSEN_PATH>");
}
"#
.replace("<FOO_PATH>", &bin_path("foo"))
Expand Down

0 comments on commit 499f917

Please sign in to comment.