Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cargo build and test built binary to ensure it works #246

Merged
merged 3 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 82 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ bugreport = "0.5.0"
itertools = "0.10.5"
cargo_toml = "0.13.0"
toml = "0.5.9"

[dev-dependencies]
assert_cmd = "2.0"
tonowak marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 31 additions & 0 deletions tests/verify_binary_contains_lints.rs
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();
}
}