Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add no lib targets test #847

Merged
merged 28 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
46a341f
Add snapshot testing with `insta`
suaviloquence Aug 2, 2024
50a7e0b
temporary dead code allows
suaviloquence Aug 2, 2024
7495147
explicitly disable backtraces
suaviloquence Aug 3, 2024
a01f75d
use `insta_cmd` for command snapshots
suaviloquence Aug 3, 2024
72f99bc
move snapshot tests to lib tests
suaviloquence Aug 3, 2024
e3ab6e9
add snapshot bin test harness
suaviloquence Aug 13, 2024
1ea8787
Revert "move snapshot tests to lib tests"
suaviloquence Aug 3, 2024
67b6fa3
Add test for no lib targets in the workspace
suaviloquence Aug 2, 2024
e7ff25b
move snapshot outputs to lib tests
suaviloquence Aug 3, 2024
d1dd661
move snapshots directory to lib tests
suaviloquence Aug 3, 2024
2c0f63a
Revert "move snapshots directory to lib tests"
suaviloquence Aug 3, 2024
12b5de7
Revert "move snapshot outputs to lib tests"
suaviloquence Aug 3, 2024
77bf46d
add test files
suaviloquence Aug 13, 2024
697a336
Add snapshot testing with `insta`
suaviloquence Aug 2, 2024
965222b
temporary dead code allows
suaviloquence Aug 2, 2024
fc492f6
explicitly disable backtraces
suaviloquence Aug 3, 2024
25493bd
use `insta_cmd` for command snapshots
suaviloquence Aug 3, 2024
66758df
move snapshot tests to lib tests
suaviloquence Aug 3, 2024
a2b15d1
add snapshot bin test harness
suaviloquence Aug 13, 2024
77c38b3
fix docs
suaviloquence Aug 15, 2024
e71e36c
clippy fixes
suaviloquence Aug 15, 2024
81f76bb
Merge branch 'add-snapshot' into add-no-lib-targets-test
suaviloquence Aug 15, 2024
ea64a90
fix merge ;(
suaviloquence Aug 15, 2024
4643dd7
...
suaviloquence Aug 15, 2024
e0c4efe
remove old test file
suaviloquence Aug 15, 2024
c1424b7
Merge branch 'main' into add-no-lib-targets-test
suaviloquence Aug 15, 2024
4fe39a4
unformat Cargo.toml
suaviloquence Aug 15, 2024
cdbefdd
clean up
suaviloquence Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/snapshot_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ impl fmt::Display for CommandResult {
/// `test_outputs/snapshot_tests/{test_name}-{"args" | "output"}.snap
/// - `invocation` is a list of arguments of the command line invocation,
/// starting with `["cargo", "semver-checks"]`.
#[allow(dead_code)] // TODO
fn assert_integration_test(test_name: &str, invocation: &[&str]) {
// remove the backtrace environment variable, as this may cause non-
// reproducible snapshots.
Expand Down Expand Up @@ -176,3 +175,23 @@ fn assert_integration_test(test_name: &str, invocation: &[&str]) {

insta::assert_snapshot!(format!("{test_name}-output"), result);
}

/// [#163](/~https://github.com/obi1kenobi/cargo-semver-checks/issues/163)
///
/// Running `cargo semver-checks --workspace` on a workspace that has library
/// targets should be an error.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, presumably?

Suggested change
/// Running `cargo semver-checks --workspace` on a workspace that has library
/// targets should be an error.
/// Running `cargo semver-checks --workspace` on a workspace that
/// doesn't have any library targets should be an error.

#[test]
fn workspace_no_lib_targets_error() {
assert_integration_test(
"workspace_no_lib_targets",
&[
"cargo",
"semver-checks",
"--manifest-path",
"test_crates/manifest_tests/no_lib_targets/new",
"--baseline-root",
"test_crates/manifest_tests/no_lib_targets/old",
"--workspace",
],
);
}
3 changes: 3 additions & 0 deletions test_crates/manifest_tests/no_lib_targets/new/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["bin_only"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "bin_only"
version = "0.1.0"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
3 changes: 3 additions & 0 deletions test_crates/manifest_tests/no_lib_targets/new/new/Cargo.toml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the addition of files under .../new/new/ intentional here?

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["bin_only"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "bin_only"
version = "0.1.0"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
3 changes: 3 additions & 0 deletions test_crates/manifest_tests/no_lib_targets/old/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["bin_only"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "bin_only"
version = "0.1.0"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
3 changes: 3 additions & 0 deletions test_crates/manifest_tests/no_lib_targets/old/new/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "2"
members = ["bin_only"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "bin_only"
version = "0.1.0"
edition = "2021"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
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/no_lib_targets/new"),
),
baseline: Rustdoc(
source: Root("test_crates/manifest_tests/no_lib_targets/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
---
--- error ---
no crates with library targets selected, nothing to semver-check
note: only library targets contain an API surface that can be checked for semver
note: skipped the following crates since they have no library target: bin_only
Loading