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

Fix workspace with default root, simplify lots walkers & metadata #532

Merged
merged 40 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2986754
Fix snapshots within a nested crate
max-sixty Jul 21, 2024
c3dbf6a
add comment
max-sixty Jul 21, 2024
4e83ac4
Always pass packages along
max-sixty Jul 21, 2024
8451e13
Change LocationInfo::packages to have the selected packages
max-sixty Jul 21, 2024
09c7522
max-sixty Jul 21, 2024
59c7101
Unify snapshot walkers
max-sixty Jul 22, 2024
fa34135
Merge branch 'master' into 396
max-sixty Jul 27, 2024
19b5947
Merge branch 'master' into unify-walkers
max-sixty Jul 27, 2024
d719036
Merge branch 'master' into unify-walkers
max-sixty Jul 28, 2024
5b54841
Include all packages when `--workspace` is passed
max-sixty Jul 28, 2024
eb4177a
Merge branch '396' into unify-walkers
max-sixty Jul 28, 2024
4ac2dc4
Merge branch 'master' into 396
max-sixty Jul 28, 2024
4d45bea
remove unneeded code now that we always have packages
max-sixty Jul 28, 2024
7fd9a01
Merge branch '396' into unify-walkers
max-sixty Jul 28, 2024
6bfea18
Merge branch 'master' into unify-walkers
max-sixty Aug 1, 2024
1e93eb3
Merge branch 'master' into 396
max-sixty Aug 1, 2024
de18c75
Merge branch 'master' into 396
max-sixty Aug 1, 2024
8ee8592
max-sixty Aug 1, 2024
2100885
Merge branch '396' into unify-walkers
max-sixty Aug 1, 2024
7dc7d6a
max-sixty Aug 1, 2024
9c1d742
Merge branch '396' into unify-walkers
max-sixty Aug 1, 2024
0a31d12
max-sixty Aug 2, 2024
e78415d
Merge branch 'master' into 396
max-sixty Aug 2, 2024
1c48750
Merge branch 'master' into unify-walkers
max-sixty Aug 2, 2024
d0533cc
Merge branch '396' into unify-walkers
max-sixty Aug 2, 2024
439cd95
Lots more refactoring & test framework improvements
max-sixty Aug 2, 2024
6a448df
max-sixty Aug 2, 2024
62fe5d6
.
max-sixty Aug 2, 2024
509aafd
max-sixty Aug 2, 2024
e0a271c
max-sixty Aug 2, 2024
7a1bd00
max-sixty Aug 2, 2024
d35b8af
Merge branch 'master' into unify-walkers
max-sixty Aug 2, 2024
d807d10
Add test showing panic from nested crate
max-sixty Aug 2, 2024
96d77b8
Merge branch 'add-current-state-in-tests' into unify-walkers
max-sixty Aug 2, 2024
a354d67
Merge branch 'master' into unify-walkers
max-sixty Aug 2, 2024
8fcfa07
max-sixty Aug 2, 2024
fd6380f
max-sixty Aug 2, 2024
e11ab9e
max-sixty Aug 3, 2024
5e8ed2c
Every snapshot belongs to a package, no need for `Option`
max-sixty Aug 3, 2024
8defa95
Merge branch 'master' into unify-walkers
max-sixty Aug 8, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to insta and cargo-insta are documented here.

## 1.40.0

- `cargo-insta` no longer panics when running `cargo test --accept --workspace`
on a workspace with a default crate. #532

- MSRV for `insta` has been raised to 1.60, and for `cargo-insta` to 1.64.

- Added support for compact debug snapshots (`assert_compact_debug_snapshot`). #514
Expand Down
35 changes: 2 additions & 33 deletions cargo-insta/src/cargo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::error::Error;
use std::path::{Path, PathBuf};
use std::path::PathBuf;

pub(crate) use cargo_metadata::{Metadata, Package};
pub(crate) use cargo_metadata::Package;

pub(crate) fn find_snapshot_roots(package: &Package) -> Vec<PathBuf> {
let mut roots = Vec::new();
Expand Down Expand Up @@ -44,33 +43,3 @@ pub(crate) fn find_snapshot_roots(package: &Package) -> Vec<PathBuf> {

reduced_roots
}

pub(crate) fn get_metadata(
manifest_path: Option<&Path>,
all: bool,
) -> Result<Metadata, Box<dyn Error>> {
let mut cmd = cargo_metadata::MetadataCommand::new();
if let Some(manifest_path) = manifest_path {
cmd.manifest_path(manifest_path);
}
if all {
cmd.no_deps();
}
let mut metadata = cmd.exec()?;
let Metadata {
packages,
workspace_members,
resolve,
..
} = &mut metadata;
match resolve
.as_ref()
.and_then(|cargo_metadata::Resolve { root, .. }| root.as_ref())
{
Some(root) => packages.retain(|Package { id, .. }| id == root),
None => {
packages.retain(|Package { id, .. }| workspace_members.contains(id));
}
}
Ok(metadata)
}
Loading
Loading