Skip to content

Commit

Permalink
Test that config is only read from new (i.e., current) manifest (#814)
Browse files Browse the repository at this point in the history
add test to read new manifest
  • Loading branch information
suaviloquence authored Jul 12, 2024
1 parent 363754a commit 48a7fac
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
publish = false
name = "only-read-new-manifest"
version = "0.1.0"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This will be removed in the `new` version to trigger the `struct_missing` lint.
// This is configured to `allow` in `old/Cargo.toml` (the baseline version),
// but this should not affect the lint level as the configuration should only be
// read from the `new` (current) manifest, so the `struct_missing` lint should
// still trigger.
// pub struct StructMissing;
10 changes: 10 additions & 0 deletions test_crates/manifest_tests/only_read_new_manifest/old/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
publish = false
name = "only-read-new-manifest"
version = "0.1.0"
edition = "2021"

[dependencies]

[package.metadata.cargo-semver-checks.lints]
struct_missing = "allow"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This will be removed in the `new` version to trigger the `struct_missing` lint.
// This is configured to `allow` in `old/Cargo.toml` (the baseline version),
// but this should not affect the lint level as the configuration should only be
// read from the `new` (current) manifest, so the `struct_missing` lint should
// still trigger.
pub struct StructMissing;
12 changes: 12 additions & 0 deletions tests/lint_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,15 @@ fn test_workspace_key_cargo_true() {
fn test_workspace_key_both_missing() {
test_workspace_key_overrided("both_missing", false);
}

/// Tests that config overrides are only read from the new/current
/// manifest and not the old/baseline manifest. In `old/Cargo.toml`,
/// `struct_missing` is configured to allow, but this should not apply
/// and the lint should still be triggered.
#[test]
fn test_only_read_config_from_new_manifest() {
let assert = command_for_crate("only_read_new_manifest").assert();
assert
.stderr(predicates::str::is_match("FAIL(.*)struct_missing").expect("regex should be valid"))
.failure();
}

0 comments on commit 48a7fac

Please sign in to comment.