-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snapshot test for when a workspace member's baseline has a compil…
…e error. (#882) * add test when a workspace member's baseline has a compile error * rerun snapshot * experiment: set CARGO_TERM_VERBOSE to false explicitly * try quiet * skip test on < cargo 1.78
- Loading branch information
1 parent
c2dfe22
commit 6e5d78a
Showing
13 changed files
with
163 additions
and
0 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
3 changes: 3 additions & 0 deletions
3
test_crates/manifest_tests/workspace_baseline_compile_error/new/Cargo.toml
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 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["error", "no-error"] |
6 changes: 6 additions & 0 deletions
6
test_crates/manifest_tests/workspace_baseline_compile_error/new/error/Cargo.toml
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 @@ | ||
[package] | ||
name = "error" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
5 changes: 5 additions & 0 deletions
5
test_crates/manifest_tests/workspace_baseline_compile_error/new/error/src/lib.rs
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,5 @@ | ||
//! Has a compile error in the baseline version, | ||
//! so we can't generate the rustdoc JSON to | ||
//! run semver-checks on | ||
// in baseline: | ||
// compile_error!("This crate has a compiler error."); |
6 changes: 6 additions & 0 deletions
6
test_crates/manifest_tests/workspace_baseline_compile_error/new/no-error/Cargo.toml
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 @@ | ||
[package] | ||
name = "no-error" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
4 changes: 4 additions & 0 deletions
4
test_crates/manifest_tests/workspace_baseline_compile_error/new/no-error/src/lib.rs
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,4 @@ | ||
//! This crate removes the function `my_fn` in the new version | ||
//! which is a `function_missing` major semver error. | ||
// removed in new version: | ||
// pub fn my_fn() {} |
3 changes: 3 additions & 0 deletions
3
test_crates/manifest_tests/workspace_baseline_compile_error/old/Cargo.toml
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 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["error", "no-error"] |
6 changes: 6 additions & 0 deletions
6
test_crates/manifest_tests/workspace_baseline_compile_error/old/error/Cargo.toml
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 @@ | ||
[package] | ||
name = "error" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
4 changes: 4 additions & 0 deletions
4
test_crates/manifest_tests/workspace_baseline_compile_error/old/error/src/lib.rs
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,4 @@ | ||
//! Has a compile error in the baseline version, | ||
//! so we can't generate the rustdoc JSON to | ||
//! run semver-checks on | ||
compile_error!("This crate has a compiler error."); |
6 changes: 6 additions & 0 deletions
6
test_crates/manifest_tests/workspace_baseline_compile_error/old/no-error/Cargo.toml
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 @@ | ||
[package] | ||
name = "no-error" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] |
3 changes: 3 additions & 0 deletions
3
test_crates/manifest_tests/workspace_baseline_compile_error/old/no-error/src/lib.rs
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 @@ | ||
//! This crate removes the function `my_fn` in the new version | ||
//! which is a `function_missing` major semver error. | ||
pub fn my_fn() {} |
30 changes: 30 additions & 0 deletions
30
...ot_tests/cargo_semver_checks__snapshot_tests__workspace_baseline_compile_error-input.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,30 @@ | ||
--- | ||
source: src/snapshot_tests.rs | ||
expression: check | ||
--- | ||
Check( | ||
scope: Scope( | ||
mode: DenyList(PackageSelection( | ||
selection: Workspace, | ||
excluded_packages: [], | ||
)), | ||
), | ||
current: Rustdoc( | ||
source: Root("test_crates/manifest_tests/workspace_baseline_compile_error/new"), | ||
), | ||
baseline: Rustdoc( | ||
source: Root("test_crates/manifest_tests/workspace_baseline_compile_error/old"), | ||
), | ||
release_type: None, | ||
current_feature_config: FeatureConfig( | ||
features_group: Heuristic, | ||
extra_features: [], | ||
is_baseline: false, | ||
), | ||
baseline_feature_config: FeatureConfig( | ||
features_group: Heuristic, | ||
extra_features: [], | ||
is_baseline: true, | ||
), | ||
build_target: None, | ||
) |
54 changes: 54 additions & 0 deletions
54
...t_tests/cargo_semver_checks__snapshot_tests__workspace_baseline_compile_error-output.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: src/snapshot_tests.rs | ||
expression: result | ||
--- | ||
--- error --- | ||
aborting due to failure to build rustdoc for crate error v0.1.0 | ||
--- stdout --- | ||
|
||
--- failure function_missing: pub fn removed or renamed --- | ||
|
||
Description: | ||
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function 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/v0.34.0/src/lints/function_missing.ron | ||
|
||
Failed in: | ||
function no_error::my_fn, previously in file [ROOT]/test_crates/manifest_tests/workspace_baseline_compile_error/old/no-error/src/lib.rs:3 | ||
|
||
--- stderr --- | ||
Parsing error v0.1.0 (current) | ||
Parsed [TIME] (current) | ||
Parsing error v0.1.0 (baseline) | ||
error: running cargo-doc on crate error failed with output: | ||
----- | ||
Documenting error v0.1.0 ([ROOT]/test_crates/manifest_tests/workspace_baseline_compile_error/old/error) | ||
error: This crate has a compiler error. | ||
--> [ROOT]/test_crates/manifest_tests/workspace_baseline_compile_error/old/error/src/lib.rs:4:1 | ||
| | ||
4 | compile_error!("This crate has a compiler error."); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: could not document `error` | ||
|
||
----- | ||
|
||
error: failed to build rustdoc for crate error v0.1.0 | ||
note: this is usually due to a compilation error in the crate, | ||
and is unlikely to be a bug in cargo-semver-checks | ||
note: the following command can be used to reproduce the compilation error: | ||
cargo new --lib example && | ||
cd example && | ||
echo '[workspace]' >> Cargo.toml && | ||
cargo add --path test_crates/manifest_tests/workspace_baseline_compile_error/old/error --no-default-features && | ||
cargo check | ||
|
||
Parsing no-error v0.1.0 (current) | ||
Parsed [TIME] (current) | ||
Parsing no-error v0.1.0 (baseline) | ||
Parsed [TIME] (baseline) | ||
Checking no-error v0.1.0 -> v0.1.0 (no change) | ||
Checked [TIME] [TOTAL] checks: [PASS] pass, 1 fail, 0 warn, 0 skip | ||
|
||
Summary semver requires new major version: 1 major and 0 minor checks failed | ||
Finished [TIME] no-error |