Skip to content

Commit

Permalink
Add test for when all members in a workspace are publish = false (#859
Browse files Browse the repository at this point in the history
)

* Add snapshot testing with `insta`

* temporary dead code allows

* explicitly disable backtraces

* use `insta_cmd` for command snapshots

* move snapshot tests to lib tests

* add snapshot bin test harness

* Revert "move snapshot tests to lib tests"

This reverts commit 72f99bc.

* Add test for no lib targets in the workspace

* move snapshot outputs to lib tests

* move snapshots directory to lib tests

* Revert "move snapshots directory to lib tests"

This reverts commit b56a113.

* Revert "move snapshot outputs to lib tests"

This reverts commit 8b6494c.

* add test files

* Add test for all workspace members `publish = false`

* Add snapshot testing with `insta`

* temporary dead code allows

* explicitly disable backtraces

* use `insta_cmd` for command snapshots

* move snapshot tests to lib tests

* add snapshot bin test harness

* fix docs

* clippy fixes

* fix merge ;(

* ...

* remove old test file

* delete crates again
  • Loading branch information
suaviloquence authored Aug 16, 2024
1 parent 0ed4827 commit c53ff88
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/snapshot_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,23 @@ fn workspace_no_lib_targets_error() {
],
);
}

/// [#424](/~https://github.com/obi1kenobi/cargo-semver-checks/issues/424)
///
/// Running `cargo semver-checks --workspace` on a workspace whose members are all
/// `publish = false`.
#[test]
fn workspace_all_publish_false() {
assert_integration_test(
"workspace_all_publish_false",
&[
"cargo",
"semver-checks",
"--manifest-path",
"test_crates/manifest_tests/workspace_all_publish_false/new",
"--baseline-root",
"test_crates/manifest_tests/workspace_all_publish_false/old",
"--workspace",
],
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["a", "b"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "a"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Removed in new version, so would trigger `function_missing` lint,
// but this crate is set to `publish = false`, so `cargo-semver-checks`
// should not check it.
// pub fn should_not_run() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "b"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// An empty library target with `publish = false`, that should
// not be semver-checked.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["a", "b"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "a"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Removed in new version, so would trigger `function_missing` lint,
// but this crate is set to `publish = false`, so `cargo-semver-checks`
// should not check it.
pub fn should_not_run() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "b"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// An empty library target with `publish = false`, that should
// not be semver-checked.
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_all_publish_false/new"),
),
baseline: Rustdoc(
source: Root("test_crates/manifest_tests/workspace_all_publish_false/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,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
source: src/snapshot_tests.rs
expression: result
---
success: true
--- stdout ---

--- stderr ---

0 comments on commit c53ff88

Please sign in to comment.