Skip to content

Commit 48a7fac

Browse files
Test that config is only read from new (i.e., current) manifest (#814)
add test to read new manifest
1 parent 363754a commit 48a7fac

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
publish = false
3+
name = "only-read-new-manifest"
4+
version = "0.1.0"
5+
edition = "2021"
6+
7+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This will be removed in the `new` version to trigger the `struct_missing` lint.
2+
// This is configured to `allow` in `old/Cargo.toml` (the baseline version),
3+
// but this should not affect the lint level as the configuration should only be
4+
// read from the `new` (current) manifest, so the `struct_missing` lint should
5+
// still trigger.
6+
// pub struct StructMissing;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
publish = false
3+
name = "only-read-new-manifest"
4+
version = "0.1.0"
5+
edition = "2021"
6+
7+
[dependencies]
8+
9+
[package.metadata.cargo-semver-checks.lints]
10+
struct_missing = "allow"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This will be removed in the `new` version to trigger the `struct_missing` lint.
2+
// This is configured to `allow` in `old/Cargo.toml` (the baseline version),
3+
// but this should not affect the lint level as the configuration should only be
4+
// read from the `new` (current) manifest, so the `struct_missing` lint should
5+
// still trigger.
6+
pub struct StructMissing;

tests/lint_config.rs

+12
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,15 @@ fn test_workspace_key_cargo_true() {
128128
fn test_workspace_key_both_missing() {
129129
test_workspace_key_overrided("both_missing", false);
130130
}
131+
132+
/// Tests that config overrides are only read from the new/current
133+
/// manifest and not the old/baseline manifest. In `old/Cargo.toml`,
134+
/// `struct_missing` is configured to allow, but this should not apply
135+
/// and the lint should still be triggered.
136+
#[test]
137+
fn test_only_read_config_from_new_manifest() {
138+
let assert = command_for_crate("only_read_new_manifest").assert();
139+
assert
140+
.stderr(predicates::str::is_match("FAIL(.*)struct_missing").expect("regex should be valid"))
141+
.failure();
142+
}

0 commit comments

Comments
 (0)