Skip to content

Commit

Permalink
Run cargo build and test built binary to ensure it works (#246)
Browse files Browse the repository at this point in the history
* 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
tonowak committed Dec 27, 2022
1 parent 1a4a7e9 commit fc5aa9e
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 1 deletion.
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"
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();
}
}

0 comments on commit fc5aa9e

Please sign in to comment.