-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve
RUSTDOCFLAGS
so that custom --cfg
settings can be applie…
…d. (#1016) Allow users to set `--cfg` options included when scanning a crate by invoking the tool as: ``` RUSTDOCFLAGS="--cfg your-cfg-value" cargo semver-checks ```
- Loading branch information
1 parent
844146f
commit 62817c9
Showing
11 changed files
with
227 additions
and
6 deletions.
There are no files selected for viewing
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
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,7 @@ | ||
[package] | ||
publish = false | ||
name = "cfg_conditional_compilation" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,3 @@ | ||
fn main() { | ||
println!("cargo::rustc-check-cfg=cfg(custom)"); | ||
} |
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,6 @@ | ||
pub enum Data { | ||
Int(i64), | ||
String(String), | ||
#[cfg(custom)] | ||
Bool(bool), | ||
} |
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,7 @@ | ||
[package] | ||
publish = false | ||
name = "cfg_conditional_compilation" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
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,3 @@ | ||
fn main() { | ||
println!("cargo::rustc-check-cfg=cfg(custom)"); | ||
} |
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,7 @@ | ||
#[cfg(custom)] | ||
pub struct Example; | ||
|
||
pub enum Data { | ||
Int(i64), | ||
String(String), | ||
} |
54 changes: 54 additions & 0 deletions
54
test_outputs/integration_snapshots__cfg_conditional_compilation.snap
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,54 @@ | ||
--- | ||
source: tests/integration_snapshots.rs | ||
info: | ||
program: cargo-semver-checks | ||
args: | ||
- semver-checks | ||
- "--manifest-path" | ||
- test_crates/cfg_conditional_compilation/new | ||
- "--baseline-root" | ||
- test_crates/cfg_conditional_compilation/old | ||
env: | ||
CARGO_TERM_COLOR: never | ||
RUSTDOCFLAGS: "--cfg custom" | ||
RUSTFLAGS: "--cfg custom" | ||
RUST_BACKTRACE: "0" | ||
--- | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
|
||
--- failure enum_variant_added: enum variant added on exhaustive enum --- | ||
|
||
Description: | ||
A publicly-visible enum without #[non_exhaustive] has a new variant. | ||
ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new | ||
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/[VERSION]/src/lints/enum_variant_added.ron | ||
|
||
Failed in: | ||
variant Data:Bool in [ROOT]/test_crates/cfg_conditional_compilation/new/src/lib.rs:5 | ||
|
||
--- failure struct_missing: pub struct removed or renamed --- | ||
|
||
Description: | ||
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely. | ||
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove | ||
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/[VERSION]/src/lints/struct_missing.ron | ||
|
||
Failed in: | ||
struct cfg_conditional_compilation::Example, previously in file [ROOT]/test_crates/cfg_conditional_compilation/old/src/lib.rs:2 | ||
|
||
----- stderr ----- | ||
Building cfg_conditional_compilation v0.1.0 (current) | ||
Built [TIME] (current) | ||
Parsing cfg_conditional_compilation v0.1.0 (current) | ||
Parsed [TIME] (current) | ||
Building cfg_conditional_compilation v0.1.0 (baseline) | ||
Built [TIME] (baseline) | ||
Parsing cfg_conditional_compilation v0.1.0 (baseline) | ||
Parsed [TIME] (baseline) | ||
Checking cfg_conditional_compilation v0.1.0 -> v0.1.0 (no change) | ||
Checked [TIME] [TOTAL] checks: [PASS] pass, 2 fail, 0 warn, 0 skip | ||
|
||
Summary semver requires new major version: 2 major and 0 minor checks failed | ||
Finished [TIME] cfg_conditional_compilation |
31 changes: 31 additions & 0 deletions
31
test_outputs/integration_snapshots__cfg_conditional_compilation_without_cfg_set.snap
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 @@ | ||
--- | ||
source: tests/integration_snapshots.rs | ||
info: | ||
program: cargo-semver-checks | ||
args: | ||
- semver-checks | ||
- "--manifest-path" | ||
- test_crates/cfg_conditional_compilation/new | ||
- "--baseline-root" | ||
- test_crates/cfg_conditional_compilation/old | ||
env: | ||
CARGO_TERM_COLOR: never | ||
RUST_BACKTRACE: "0" | ||
--- | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
|
||
----- stderr ----- | ||
Building cfg_conditional_compilation v0.1.0 (current) | ||
Built [TIME] (current) | ||
Parsing cfg_conditional_compilation v0.1.0 (current) | ||
Parsed [TIME] (current) | ||
Building cfg_conditional_compilation v0.1.0 (baseline) | ||
Built [TIME] (baseline) | ||
Parsing cfg_conditional_compilation v0.1.0 (baseline) | ||
Parsed [TIME] (baseline) | ||
Checking cfg_conditional_compilation v0.1.0 -> v0.1.0 (no change) | ||
Checked [TIME] [TOTAL] checks: [PASS] pass, 0 skip | ||
Summary no semver update required | ||
Finished [TIME] cfg_conditional_compilation |
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