-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run cargo build and test built binary to ensure it works (#246)
* Run cargo build and test built binary to ensure it works * Moved the test from GitHub CI to a test in `src/main.rs` * Moved `verify_binary_contains_lints` to `tests/`
- Loading branch information
Showing
3 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,31 @@ | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn verify_binary_contains_lints() { | ||
let assert_on_crate_pair = |crate_pair: &str| { | ||
let mut cmd = Command::cargo_bin("cargo-semver-checks").unwrap(); | ||
cmd.current_dir(format!("test_crates/{crate_pair}/new")) | ||
.args([ | ||
"semver-checks", | ||
"check-release", | ||
"--baseline-root=../old/Cargo.toml", | ||
]) | ||
.assert() | ||
}; | ||
|
||
// The `template/new` and `template/old` are identical crates, so running cargo-semver-checks on | ||
// them shouldn't report any issues. | ||
assert_on_crate_pair("template").success(); | ||
|
||
// Those test crate pairs should trigger an error (because of a lint with the same name), | ||
// so they should return a non-zero exit code. | ||
// Only a few (arbitrarily) lints are being checked to speed up the testing process (the full | ||
// list of lints is tested in `src/query.rs`). | ||
for crate_pair in [ | ||
"enum_missing", | ||
"function_const_removed", | ||
"function_unsafe_added", | ||
] { | ||
assert_on_crate_pair(crate_pair).failure(); | ||
} | ||
} |