Skip to content

Commit

Permalink
Cargo.toml: add crates to workspace
Browse files Browse the repository at this point in the history
This allows IDE integration to work when the root of the repository is
opened. Prior to this change, a developer would have to open cargo-insta
to get code completion for that crate.

This also causes clippy to run on all crates, so this commit fixes a few
lints.
  • Loading branch information
tamird committed Oct 9, 2023
1 parent ef00fb6 commit 4f9c17a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
12 changes: 8 additions & 4 deletions Cargo.toml
Expand Up @@ -10,14 +10,15 @@ homepage = "https://insta.rs/"
repository = "https://github.com/mitsuhiko/insta"
keywords = ["snapshot", "testing", "jest", "approval"]
readme = "README.md"
exclude = [
"assets/*"
]
exclude = ["assets/*"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace]
members = ["cargo-insta", "cargo-insta/integration-tests"]

[features]
default = ["colors"]

Expand Down Expand Up @@ -56,7 +57,10 @@ dep_toml = { package = "toml", version = "0.5.7", optional = true }
globset = { version = "0.4.6", optional = true }
walkdir = { version = "2.3.1", optional = true }
similar = { version = "2.1.0", features = ["inline"] }
regex = { version = "1.6.0", default-features = false, optional = true, features = ["std", "unicode"] }
regex = { version = "1.6.0", default-features = false, optional = true, features = [
"std",
"unicode",
] }
yaml-rust = "0.4.5"
serde = { version = "1.0.117", optional = true }
linked-hash-map = "0.5.6"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -40,6 +40,6 @@ format-check:

lint:
@rustup component add clippy 2> /dev/null
@cargo clippy
@cargo clippy --all-targets --workspace -- --deny warnings

.PHONY: all doc test cargotest format format-check lint update-readme
3 changes: 1 addition & 2 deletions cargo-insta/integration-tests/src/main.rs
Expand Up @@ -46,11 +46,10 @@ fn main() {
.unwrap()
.to_str()
.unwrap();
if filename.ends_with(".rs") {
if let Some(snapshot) = filename.strip_suffix(".rs") {
let gen_file = Path::new("tests").join(filename);
let mut settings = Settings::clone_current();
settings.set_input_file(&gen_file);
let snapshot = &filename[..filename.len() - 3];
settings.bind(|| {
assert_snapshot!(snapshot, &fs::read_to_string(gen_file).unwrap());
});
Expand Down
3 changes: 3 additions & 0 deletions cargo-insta/src/cli.rs
Expand Up @@ -45,6 +45,7 @@ struct Opts {
bin_name = "cargo insta",
after_help = "For the online documentation of the latest version, see https://insta.rs/docs/cli/."
)]
#[allow(clippy::large_enum_variant)]
enum Command {
/// Interactively review snapshots
#[structopt(name = "review", alias = "verify")]
Expand Down Expand Up @@ -415,6 +416,7 @@ fn handle_target_args(target_args: &TargetArgs) -> Result<LocationInfo<'_>, Box<
}
}

#[allow(clippy::type_complexity)]
fn load_snapshot_containers<'a>(
loc: &'a LocationInfo,
) -> Result<
Expand Down Expand Up @@ -775,6 +777,7 @@ fn handle_unreferenced_snapshots(
Ok(())
}

#[allow(clippy::type_complexity)]
fn prepare_test_runner<'snapshot_ref>(
test_runner: TestRunner,
unreferenced: UnreferencedSnapshots,
Expand Down
2 changes: 1 addition & 1 deletion cargo-insta/src/inline.rs
Expand Up @@ -104,7 +104,7 @@ impl FilePatcher {

// replace lines
let snapshot_line_contents =
vec![prefix, snapshot.to_inline(inline.indentation), suffix].join("");
[prefix, snapshot.to_inline(inline.indentation), suffix].join("");

self.lines.splice(
inline.start.0..=inline.end.0,
Expand Down
2 changes: 1 addition & 1 deletion src/snapshot.rs
Expand Up @@ -727,7 +727,7 @@ b"[1..];
);

let t = "ab";
assert_eq!(SnapshotContents(t.to_string()).to_inline(0), r##""ab""##);
assert_eq!(SnapshotContents(t.to_string()).to_inline(0), r#""ab""#);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_clash_detection.rs
Expand Up @@ -44,7 +44,7 @@ fn test_clash_detection() {

let s1 = err1.downcast_ref::<String>().unwrap();
let s2 = err2.downcast_ref::<String>().unwrap();
let mut values = vec![s1.as_str(), s2.as_str()];
let mut values = [s1.as_str(), s2.as_str()];
values.sort();
assert_eq!(&values[..], &vec![
"Insta snapshot name clash detected between \'foo_always_missing\' and \'test_foo_always_missing\' in \'test_clash_detection\'. Rename one function.",
Expand Down

0 comments on commit 4f9c17a

Please sign in to comment.