-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect when
build.target
is configured, and allow overriding it fro…
…m the command line (#619) * Detect when `build.target` is configured This allows checking the correct directory for the json files. There are two more correct approaches to this, but neither are usable currently: 1. The most correct approach would be to read the `compiler-artifact` messages from `cargo --message-format=json`. Unfortunately as of the current nightly these don't work when using `--output-format=json`, they have an empty list of files. 2. The next option would be to use `--out-dir` to tell cargo/rustdoc to place the json file in a known directory. As of the current nightly cargo doesn't support `--out-dir` with `cargo doc`, and attempting to pass it through to rustdoc directly results in an error because it is given more than once. So instead, we query cargo to see if the user has configured `build.target` through either a config file or environment variables. * Add flag to specify which target to build for * Add tests for both implicit and explicit targets * Improve the unset config value detection * Use `build_target` internally to refer to the target platform * Add example target to CLI docs * Add more documentation around setting the `--target`
- Loading branch information
Showing
5 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use assert_cmd::Command; | ||
|
||
fn base() -> Command { | ||
let mut cmd = Command::cargo_bin("cargo-semver-checks").unwrap(); | ||
cmd.args([ | ||
"semver-checks", | ||
"check-release", | ||
"--manifest-path=test_crates/template/new", | ||
"--baseline-root=test_crates/template/old", | ||
]); | ||
cmd | ||
} | ||
|
||
#[test] | ||
fn with_default() { | ||
base().env_remove("CARGO_BUILD_TARGET").assert().success(); | ||
} | ||
|
||
#[test] | ||
fn with_env_var() { | ||
base() | ||
.env("CARGO_BUILD_TARGET", "x86_64-unknown-linux-gnu") | ||
.assert() | ||
.success(); | ||
} | ||
|
||
#[test] | ||
fn with_flag() { | ||
base() | ||
.env_remove("CARGO_BUILD_TARGET") | ||
.arg("--target=x86_64-unknown-linux-gnu") | ||
.assert() | ||
.success(); | ||
} |