From 8a33b66c7ee13b074e9524273b72a638d2ba732f Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 11:36:58 -0700 Subject: [PATCH 01/21] Improve docs for snapshot updates This attempts to clarify when snapshots are written to draft `.snap.new` files as opposed to overwriting `.snap` files --- cargo-insta/src/walk.rs | 3 +- insta/src/lib.rs | 79 ++++++++++++++++++++--------------------- insta/src/runtime.rs | 3 +- insta/src/snapshot.rs | 3 +- 4 files changed, 42 insertions(+), 46 deletions(-) diff --git a/cargo-insta/src/walk.rs b/cargo-insta/src/walk.rs index 7a3b618b..2c96e83a 100644 --- a/cargo-insta/src/walk.rs +++ b/cargo-insta/src/walk.rs @@ -35,8 +35,7 @@ pub(crate) fn find_snapshots<'a>( let fname = e.file_name().to_string_lossy(); if fname.ends_with(".new") { let new_path = e.into_path(); - let mut old_path = new_path.clone(); - old_path.set_extension(""); + let old_path = new_path.clone().with_extension(""); Some(SnapshotContainer::load( new_path, old_path, diff --git a/insta/src/lib.rs b/insta/src/lib.rs index ebbd6b3a..ecc4fd8d 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -100,56 +100,54 @@ //! # Snapshot updating //! //! During test runs snapshots will be updated according to the `INSTA_UPDATE` -//! environment variable. The default is `auto` which will write all new -//! snapshots into `.snap.new` files if no CI is detected so that -//! [`cargo-insta`](https://crates.io/crates/cargo-insta) -//! can pick them up. Normally you don't have to change this variable. +//! environment variable. The default is `auto` which will write failing +//! snapshot assertions into `.snap.new` files (if no CI is detected) so that +//! [`cargo-insta`](https://crates.io/crates/cargo-insta) can pick them up for +//! review. Normally you don't have to change this variable. //! //! `INSTA_UPDATE` modes: //! //! - `auto`: the default. `no` for CI environments or `new` otherwise -//! - `always`: overwrites old snapshot files with new ones unasked -//! - `unseen`: behaves like `always` for new snapshots and `new` for others -//! - `new`: write new snapshots into `.snap.new` files -//! - `no`: does not update snapshot files at all (just runs tests) -//! -//! When `new` or `auto` is used as mode the [`cargo-insta`](https://crates.io/crates/cargo-insta) -//! command can be used to review the snapshots conveniently: +//! - `new`: writes failing snapshot assersions into `.snap.new` files[^1], in +//! preparation for review +//! - `always`: accepts any failing snapshot assertions into `.snap` files, +//! bypassing review +//! - `unseen`: behaves like `always` for previously unseen snapshots and `new` +//! for existing snapshots +//! - `no`: does not update snapshot files at all; just runs tests +//! +//! When `new`, `auto` or `unseen` is used, the +//! [`cargo-insta`](https://crates.io/crates/cargo-insta) command can be used to +//! review the snapshots conveniently: //! //! ```text //! $ cargo insta review //! ``` //! -//! "enter" or "a" accepts a new snapshot, "escape" or "r" rejects, -//! "space" or "s" skips the snapshot for now. +//! "enter" or "a" accepts a new snapshot, "escape" or "r" rejects, "space" or +//! "s" skips the snapshot for now. //! -//! For more information [read the cargo insta docs](https://insta.rs/docs/cli/). +//! For more information [read the cargo insta +//! docs](https://insta.rs/docs/cli/). //! //! # Inline Snapshots //! //! Additionally snapshots can also be stored inline. In that case the format //! for the snapshot macros is `assert_snapshot!(reference_value, @"snapshot")`. //! The leading at sign (`@`) indicates that the following string is the -//! reference value. `cargo-insta` will then update that string with the new -//! value on review. +//! reference value. On review, `cargo-insta` will update the string with the +//! new value. //! //! Example: //! -#![cfg_attr(feature = "yaml", doc = " ```no_run")] -#![cfg_attr(not(feature = "yaml"), doc = " ```ignore")] -//! # use insta::*; use serde::Serialize; -//! #[derive(Serialize)] -//! pub struct User { -//! username: String, -//! } -//! -//! assert_yaml_snapshot!(User { -//! username: "john_doe".to_string(), -//! }, @""); +//! ```no_run +//! assert_snapshot!(2 + 2, @""); //! ``` //! -//! Like with normal snapshots after the initial test failure you can run -//! `cargo insta review` to accept the change. The file will then be updated +//! Like with normal snapshots, an initial test failure will write the proposed +//! value into a draft file (note that inline snapshots use `.pending-snap` +//! files rather than `.snap.new` files). Running `cargo insta review` will +//! review the proposed changes and update the source files on acceptance //! automatically. //! //! # Features @@ -166,9 +164,9 @@ //! * `glob`: enables support for globbing ([`glob!`]) //! * `colors`: enables color output (enabled by default) //! -//! For legacy reasons the `json` and `yaml` features are enabled by default -//! in limited capacity. You will receive a deprecation warning if you are -//! not opting into them but for now the macros will continue to function. +//! For legacy reasons the `json` and `yaml` features are enabled by default in +//! limited capacity. You will receive a deprecation warning if you are not +//! opting into them but for now the macros will continue to function. //! //! Enabling any of the serde based formats enables the hidden `serde` feature //! which gates some serde specific APIs such as [`Settings::set_info`]. @@ -177,10 +175,10 @@ //! //! `insta` tries to be light in dependencies but this is tricky to accomplish //! given what it tries to do. By default it currently depends on `serde` for -//! the [`assert_toml_snapshot!`] and [`assert_yaml_snapshot!`] macros. In -//! the future this default dependencies will be removed. To already benefit -//! from this optimization you can disable the default features and manually -//! opt into what you want. +//! the [`assert_toml_snapshot!`] and [`assert_yaml_snapshot!`] macros. In the +//! future this default dependencies will be removed. To already benefit from +//! this optimization you can disable the default features and manually opt into +//! what you want. //! //! # Settings //! @@ -229,10 +227,11 @@ //! //! # Optional: Faster Runs //! -//! Insta benefits from being compiled in release mode, even as dev dependency. It -//! will compile slightly slower once, but use less memory, have faster diffs and -//! just generally be more fun to use. To achieve that, opt `insta` and `similar` -//! (the diffing library) into higher optimization in your `Cargo.toml`: +//! Insta benefits from being compiled in release mode, even as dev dependency. +//! It will compile slightly slower once, but use less memory, have faster diffs +//! and just generally be more fun to use. To achieve that, opt `insta` and +//! `similar` (the diffing library) into higher optimization in your +//! `Cargo.toml`: //! //! ```yaml //! [profile.dev.package.insta] diff --git a/insta/src/runtime.rs b/insta/src/runtime.rs index 36342377..24a0707d 100644 --- a/insta/src/runtime.rs +++ b/insta/src/runtime.rs @@ -344,8 +344,7 @@ impl<'a> SnapshotAssertionContext<'a> { // let's just make sure there are no more pending files lingering // around. if let Some(ref snapshot_file) = self.snapshot_file { - let mut snapshot_file = snapshot_file.clone(); - snapshot_file.set_extension("snap.new"); + let snapshot_file = snapshot_file.clone().with_extension("snap.new"); fs::remove_file(snapshot_file).ok(); } diff --git a/insta/src/snapshot.rs b/insta/src/snapshot.rs index 187b0c97..5a8fc819 100644 --- a/insta/src/snapshot.rs +++ b/insta/src/snapshot.rs @@ -501,8 +501,7 @@ impl Snapshot { /// If the existing snapshot matches the new file, then `None` is returned, otherwise /// the name of the new snapshot file. pub(crate) fn save_new(&self, path: &Path) -> Result, Box> { - let mut new_path = path.to_path_buf(); - new_path.set_extension("snap.new"); + let new_path = path.to_path_buf().with_extension("snap.new"); if self.save_with_metadata(&new_path, Some(path), &self.metadata)? { Ok(Some(new_path)) } else { From 642b6a4b727b9771bfb5953030b1b358eb2117de Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 12:08:54 -0700 Subject: [PATCH 02/21] --- insta/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/insta/src/lib.rs b/insta/src/lib.rs index ecc4fd8d..94898be9 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -141,6 +141,7 @@ //! Example: //! //! ```no_run +//! # use insta::assert_snapshot; //! assert_snapshot!(2 + 2, @""); //! ``` //! From aeae8cba8cc3e1adf7ff206eaabfedfeb93b20b7 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 12:13:26 -0700 Subject: [PATCH 03/21] . --- insta/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/insta/src/lib.rs b/insta/src/lib.rs index 94898be9..34ffc930 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -108,7 +108,7 @@ //! `INSTA_UPDATE` modes: //! //! - `auto`: the default. `no` for CI environments or `new` otherwise -//! - `new`: writes failing snapshot assersions into `.snap.new` files[^1], in +//! - `new`: writes failing snapshot assersions into `.snap.new` files, in //! preparation for review //! - `always`: accepts any failing snapshot assertions into `.snap` files, //! bypassing review From 3527fa81759f61d95d64b4bb0dfb78203337a6bb Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 14:04:19 -0700 Subject: [PATCH 04/21] Use `INSTA_UPDATE=force` for forcing snapshot updates In an effort to simplify the configs, this merges the `INSTA_UPDATE` and `INSTA_FORCE_UPDATE`. I don't think it's possible to require these both; they naturally fit into the same config setting. I realized after starting this that we want to be careful about supporting new & old versions of `cargo-insta`. So this takes a conservative approach, only changing `insta` at first, but with the future updates to `cargo-insta` commented in the code. I realize that adds a bit of complication; though on balance I think simplifying the configs would be helpful. It stacks on #479, which should merge first. I'd be open to writing some tests for this if that'd be helpful. --- cargo-insta/src/cli.rs | 27 +++++++++++++------- insta/src/env.rs | 58 +++++++++++++++++++++++++++--------------- insta/src/lib.rs | 3 ++- insta/src/runtime.rs | 5 +++- 4 files changed, 61 insertions(+), 32 deletions(-) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 2a308f23..7fc24030 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -581,6 +581,9 @@ fn test_run(mut cmd: TestCommand, color: &str) -> Result<(), Box> { cmd.accept = false; } } + SnapshotUpdate::Force => { + cmd.force_update_snapshots = true; + } } // --check always implies --no-force-pass as otherwise this command does not @@ -879,24 +882,30 @@ fn prepare_test_runner<'snapshot_ref>( } proc.env( "INSTA_UPDATE", - match (cmd.check, cmd.accept_unseen) { - (true, _) => "no", - (_, true) => "unseen", - (_, false) => "new", + match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { + (true, _, _) => "no", + (_, true, _) => "unseen", + (_, false, _) => "new", + // Don't yet set `INSTA_UPDATE=force` for + // `--force-update-snapshots`, since this would break with older + // versions of insta. In late 2024, we can swap this code in. + // + // (true, _, false) => "no", + // (_, true, false) => "unseen", + // (_, false, false) => "new", + // (false, false, true) => "force", + // _ => return Err(err_msg(format!("invalid combination of flags: check={}, accept-unseen={}, force-update-snapshots={}", cmd.check, cmd.accept_unseen, cmd.force_update_snapshots))), }, ); if cmd.force_update_snapshots { - // for old versions of insta + // For older versions of insta. Eventually we can remove this, and rely + // on the `INSTA_UPDATE=force`. proc.env("INSTA_FORCE_UPDATE_SNAPSHOTS", "1"); - // for newer versions of insta proc.env("INSTA_FORCE_UPDATE", "1"); } if cmd.require_full_match { proc.env("INSTA_REQUIRE_FULL_MATCH", "1"); } - if cmd.require_full_match { - proc.env("INSTA_REQUIRE_FULL_MATCH", "1"); - } let glob_filter = cmd.glob_filter .iter() diff --git a/insta/src/env.rs b/insta/src/env.rs index c485c995..6f91accd 100644 --- a/insta/src/env.rs +++ b/insta/src/env.rs @@ -64,6 +64,7 @@ pub enum SnapshotUpdate { Unseen, New, No, + Force, } #[derive(Debug)] @@ -96,7 +97,6 @@ impl std::error::Error for Error { /// Represents a tool configuration. #[derive(Debug)] pub struct ToolConfig { - force_update_snapshots: bool, force_pass: bool, require_full_match: bool, output: OutputBehavior, @@ -144,26 +144,37 @@ impl ToolConfig { } let cfg = cfg.unwrap_or_else(|| Content::Map(Default::default())); - // support for the deprecated environment variable. This is implemented in a way that - // cargo-insta can support older and newer insta versions alike. It will set both - // variables. However if only `INSTA_FORCE_UPDATE_SNAPSHOTS` is set, we will emit - // a deprecation warning. - if env::var("INSTA_FORCE_UPDATE").is_err() { + // Support for the deprecated environment variables. This is + // implemented in a way that cargo-insta can support older and newer + // insta versions alike. `cargo-insta` will currently set + // `INSTA_FORCE_UPDATE_SNAPSHOTS` & `INSTA_FORCE_UPDATE`, and in late + // 2024 will set `INSTA_UPDATE=force` (this would break older versions + // of insta). + // + // If `INSTA_FORCE_UPDATE_SNAPSHOTS` is the only env var present we emit + // a deprecation warning, later to be expanded to `INSTA_FORCE_UPDATE`. + if env::var("INSTA_UPDATE").is_err() { + let mut force_update = false; if let Ok("1") = env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").as_deref() { - eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_FORCE_UPDATE"); - env::set_var("INSTA_FORCE_UPDATE", "1"); + eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_UPDATE=force"); + force_update = true; + } + if let Ok("1") = env::var("INSTA_FORCE_UPDATE").as_deref() { + // Don't raise a warning yet, because `cargo-insta` still uses + // this, so that it's compatible with older versions of `insta`. + // In the future, switch `cargo-insta` to use this, and raise a + // warning here. + // + // eprintln!("INSTA_FORCE_UPDATE is deprecated, use + // INSTA_UPDATE=force"); + force_update = true; + } + if force_update { + env::set_var("INSTA_UPDATE", "force"); } } Ok(ToolConfig { - force_update_snapshots: match env::var("INSTA_FORCE_UPDATE").as_deref() { - Err(_) | Ok("") => resolve(&cfg, &["behavior", "force_update"]) - .and_then(|x| x.as_bool()) - .unwrap_or(false), - Ok("0") => false, - Ok("1") => true, - _ => return Err(Error::Env("INSTA_FORCE_UPDATE")), - }, require_full_match: match env::var("INSTA_REQUIRE_FULL_MATCH").as_deref() { Err(_) | Ok("") => resolve(&cfg, &["behavior", "require_full_match"]) .and_then(|x| x.as_bool()) @@ -201,6 +212,14 @@ impl ToolConfig { let val = match env_var.as_deref() { Err(_) | Ok("") => resolve(&cfg, &["behavior", "update"]) .and_then(|x| x.as_str()) + // Legacy support for the old force update config + .or(resolve(&cfg, &["behavior", "force_update"]).and_then(|x| { + eprintln!("`force_update: true` is deprecated, use `update: force`"); + match x.as_bool() { + Some(true) => Some("force"), + _ => None, + } + })) .unwrap_or("auto"), Ok(val) => val, }; @@ -210,6 +229,7 @@ impl ToolConfig { "new" => SnapshotUpdate::New, "unseen" => SnapshotUpdate::Unseen, "no" => SnapshotUpdate::No, + "force" => SnapshotUpdate::Force, _ => return Err(Error::Env("INSTA_UPDATE")), } }, @@ -265,11 +285,6 @@ impl ToolConfig { }) } - /// Is insta told to force update snapshots? - pub fn force_update_snapshots(&self) -> bool { - self.force_update_snapshots - } - /// Should we fail if metadata doesn't match? pub fn require_full_match(&self) -> bool { self.require_full_match @@ -362,6 +377,7 @@ pub fn snapshot_update_behavior(tool_config: &ToolConfig, unseen: bool) -> Snaps } SnapshotUpdate::New => SnapshotUpdateBehavior::NewFile, SnapshotUpdate::No => SnapshotUpdateBehavior::NoUpdate, + SnapshotUpdate::Force => SnapshotUpdateBehavior::InPlace, } } diff --git a/insta/src/lib.rs b/insta/src/lib.rs index 34ffc930..43c3309a 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -115,6 +115,7 @@ //! - `unseen`: behaves like `always` for previously unseen snapshots and `new` //! for existing snapshots //! - `no`: does not update snapshot files at all; just runs tests +//! - `force`: forcibly updates snapshot files, even if assertions pass //! //! When `new`, `auto` or `unseen` is used, the //! [`cargo-insta`](https://crates.io/crates/cargo-insta) command can be used to @@ -202,7 +203,7 @@ //! # also set by INSTA_OUTPUT //! output: "diff" | "summary" | "minimal" | "none" //! # also set by INSTA_UPDATE -//! update: "auto" | "always" | "new" | "unseen" | "no" +//! update: "auto" | "new" | "always" | "no" | "unseen" | "force" //! # also set by INSTA_GLOB_FAIL_FAST //! glob_fail_fast: true/false //! diff --git a/insta/src/runtime.rs b/insta/src/runtime.rs index 24a0707d..5cda5fe5 100644 --- a/insta/src/runtime.rs +++ b/insta/src/runtime.rs @@ -680,7 +680,10 @@ pub fn assert_snapshot( if pass { ctx.cleanup_passing()?; - if tool_config.force_update_snapshots() { + if matches!( + tool_config.snapshot_update(), + crate::env::SnapshotUpdate::Force + ) { ctx.update_snapshot(new_snapshot)?; } // otherwise print information and update snapshots. From a280745536cbc82a4426328332050a4316aaf473 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 15:04:08 -0700 Subject: [PATCH 05/21] --- insta/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/insta/src/lib.rs b/insta/src/lib.rs index 34ffc930..e14223cc 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -108,13 +108,13 @@ //! `INSTA_UPDATE` modes: //! //! - `auto`: the default. `no` for CI environments or `new` otherwise -//! - `new`: writes failing snapshot assersions into `.snap.new` files, in -//! preparation for review -//! - `always`: accepts any failing snapshot assertions into `.snap` files, +//! - `new`: writes snapshots for any failing tests into `.snap.new` files, +//! pending review +//! - `always`: writes snapshots for any failing tests into `.snap` files, //! bypassing review -//! - `unseen`: behaves like `always` for previously unseen snapshots and `new` -//! for existing snapshots -//! - `no`: does not update snapshot files at all; just runs tests +//! - `unseen`: `always` for previously unseen snapshots or `new` for existing +//! snapshots +//! - `no`: does not write to snapshot files at all; just runs tests //! //! When `new`, `auto` or `unseen` is used, the //! [`cargo-insta`](https://crates.io/crates/cargo-insta) command can be used to From 8595cd1bf3f186c7675a3b594f15fdeb159a496e Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 15:06:05 -0700 Subject: [PATCH 06/21] --- insta/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/insta/src/lib.rs b/insta/src/lib.rs index 85874ab4..02826e90 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -100,8 +100,8 @@ //! # Snapshot updating //! //! During test runs snapshots will be updated according to the `INSTA_UPDATE` -//! environment variable. The default is `auto` which will write failing -//! snapshot assertions into `.snap.new` files (if no CI is detected) so that +//! environment variable. The default is `auto` which will write snapshots for +//! any failing tests into `.snap.new` files (if no CI is detected) so that //! [`cargo-insta`](https://crates.io/crates/cargo-insta) can pick them up for //! review. Normally you don't have to change this variable. //! From e5437a1dec6e4a9d91bbff86b284b004d1239e84 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 2 May 2024 17:49:17 -0700 Subject: [PATCH 07/21] --- cargo-insta/src/cli.rs | 5 +++-- insta/src/env.rs | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 7fc24030..8556023f 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -898,8 +898,9 @@ fn prepare_test_runner<'snapshot_ref>( }, ); if cmd.force_update_snapshots { - // For older versions of insta. Eventually we can remove this, and rely - // on the `INSTA_UPDATE=force`. + // Currently compatible with older versions of insta. In late 2024, we can add: + // proc.env("INSTA_UPDATE", "force"); + // And then eventually we can remove these. proc.env("INSTA_FORCE_UPDATE_SNAPSHOTS", "1"); proc.env("INSTA_FORCE_UPDATE", "1"); } diff --git a/insta/src/env.rs b/insta/src/env.rs index 6f91accd..1d015668 100644 --- a/insta/src/env.rs +++ b/insta/src/env.rs @@ -149,7 +149,7 @@ impl ToolConfig { // insta versions alike. `cargo-insta` will currently set // `INSTA_FORCE_UPDATE_SNAPSHOTS` & `INSTA_FORCE_UPDATE`, and in late // 2024 will set `INSTA_UPDATE=force` (this would break older versions - // of insta). + // of insta if we implemented immediately). // // If `INSTA_FORCE_UPDATE_SNAPSHOTS` is the only env var present we emit // a deprecation warning, later to be expanded to `INSTA_FORCE_UPDATE`. @@ -162,11 +162,12 @@ impl ToolConfig { if let Ok("1") = env::var("INSTA_FORCE_UPDATE").as_deref() { // Don't raise a warning yet, because `cargo-insta` still uses // this, so that it's compatible with older versions of `insta`. - // In the future, switch `cargo-insta` to use this, and raise a - // warning here. + // In the future, switch `cargo-insta` to use + // `INSTA_UPDATE=force`, and raise a warning for + // `INSTA_FORCE_UPDATE`. // - // eprintln!("INSTA_FORCE_UPDATE is deprecated, use - // INSTA_UPDATE=force"); + // eprintln!("INSTA_FORCE_UPDATE is deprecated, use + // INSTA_UPDATE=force"); force_update = true; } if force_update { From 4fde25ca3e0049ce509b3f8590d65d3863d4ba7e Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 3 Aug 2024 23:44:52 -0700 Subject: [PATCH 08/21] Add integration tests for both pre & post 1.39 --- Cargo.lock | 468 +++++++++++--------------------------- cargo-insta/Cargo.toml | 7 +- cargo-insta/src/cli.rs | 39 ++-- cargo-insta/src/utils.rs | 20 ++ cargo-insta/tests/main.rs | 105 ++++++++- insta/Cargo.toml | 2 +- 6 files changed, 284 insertions(+), 357 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79e2951f..d1f84827 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "0.7.19" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -23,11 +23,17 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -57,16 +63,16 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] [[package]] name = "cargo-insta" -version = "1.39.0" +version = "1.40.0" dependencies = [ "cargo_metadata", "clap", @@ -74,7 +80,9 @@ dependencies = [ "ignore", "insta", "itertools", + "lazy_static", "proc-macro2", + "semver", "serde", "serde_json", "similar", @@ -95,9 +103,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb9ac64500cc83ce4b9f8dafa78186aa008c8dea77a09b94cd307fd0cd5022a8" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -107,12 +115,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - [[package]] name = "cfg-if" version = "1.0.0" @@ -136,7 +138,7 @@ version = "4.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "351f9ad9688141ed83dfd8f5fb998a06225ef444b48ff4dc43de6d409b7fd10b" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex", "is-terminal", "strsim", @@ -163,36 +165,51 @@ checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "console" -version = "0.15.4" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b6515d269224923b26b5febea2ed42b2d5f2ce37284a4dd670fedd6cb8347a" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.42.0", + "windows-sys 0.52.0", ] [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] [[package]] -name = "crossbeam-utils" -version = "0.8.11" +name = "crossbeam-deque" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", - "once_cell", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-common" version = "0.1.6" @@ -249,45 +266,25 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "cc", "libc", + "windows-sys 0.52.0", ] [[package]] name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fnv" -version = "1.0.7" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -295,9 +292,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -306,15 +303,15 @@ dependencies = [ [[package]] name = "globset" -version = "0.4.9" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", - "bstr 0.2.17", - "fnv", + "bstr 1.10.0", "log", - "regex", + "regex-automata 0.4.7", + "regex-syntax", ] [[package]] @@ -325,31 +322,29 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "ignore" -version = "0.4.18" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ - "crossbeam-utils", + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.7", "same-file", - "thread_local", "walkdir", "winapi-util", ] [[package]] name = "insta" -version = "1.39.0" +version = "1.40.0" dependencies = [ "clap", "console", @@ -369,26 +364,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "is-terminal" version = "0.4.12" @@ -417,21 +392,21 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linked-hash-map" @@ -441,18 +416,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.3.8" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.17" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" @@ -462,9 +434,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" -version = "1.14.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pest" @@ -529,23 +501,15 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" -version = "1.6.0" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", + "regex-automata 0.4.7", "regex-syntax", ] @@ -560,12 +524,17 @@ name = "regex-automata" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "ron" @@ -574,7 +543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" dependencies = [ "base64", - "bitflags", + "bitflags 1.3.2", "serde", ] @@ -589,23 +558,22 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.27" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -618,9 +586,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.19" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" dependencies = [ "serde", ] @@ -647,11 +615,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ - "itoa 1.0.3", + "itoa 1.0.11", "ryu", "serde", ] @@ -706,15 +674,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.5.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "once_cell", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] @@ -746,15 +714,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thread_local" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" -dependencies = [ - "once_cell", -] - [[package]] name = "toml" version = "0.5.11" @@ -766,57 +725,56 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "unicode-ident" -version = "1.0.4" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "uuid" -version = "1.1.2" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", ] [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -826,68 +784,13 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-targets 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -896,37 +799,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.0" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows-targets", ] [[package]] @@ -935,64 +817,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1005,72 +851,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/cargo-insta/Cargo.toml b/cargo-insta/Cargo.toml index 1f6384c1..fce4a6ca 100644 --- a/cargo-insta/Cargo.toml +++ b/cargo-insta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-insta" -version = "1.39.0" +version = "1.40.0" license = "Apache-2.0" authors = ["Armin Ronacher "] description = "A review tool for the insta snapshot testing library for Rust" @@ -14,7 +14,7 @@ readme = "README.md" rust-version = "1.64.0" [dependencies] -insta = { version = "=1.39.0", path = "../insta", features = ["json", "yaml", "redactions", "_cargo_insta_internal"] } +insta = { version = "=1.40.0", path = "../insta", features = ["json", "yaml", "redactions", "_cargo_insta_internal"] } cargo_metadata = { version = "0.18.0", default-features = false } console = "0.15.4" serde = { version = "1.0.117", features = ["derive"] } @@ -25,6 +25,9 @@ syn = { version = "=2.0.8", features = ["full", "visit", "extra-traits"] } ignore = "0.4.17" uuid = { version = "1.0.0", features = ["v4"] } tempfile = "3.5.0" +# Pinned because of MSRV; wait for MSRV bump or msrv-resolver +semver = {version = "=1.0.7", features = ["serde"]} +lazy_static = "1.4.0" # Not yet supported in our MSRV of 1.60.0 # clap = { workspace=true } clap = {version = "=4.1", features = ["derive", "env"]} diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 381c166b..fdab6766 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -11,11 +11,13 @@ use insta::Snapshot; use insta::_cargo_insta_support::{ is_ci, SnapshotPrinter, SnapshotUpdate, TestRunner, ToolConfig, UnreferencedSnapshots, }; +use semver::Version; use serde::Serialize; use uuid::Uuid; use crate::cargo::{find_snapshot_roots, get_metadata, Metadata, Package}; use crate::container::{Operation, SnapshotContainer}; +use crate::utils::INSTA_VERSION; use crate::utils::{err_msg, QuietExit}; use crate::walk::{find_snapshots, make_deletion_walker, make_snapshot_walker, FindFlags}; @@ -893,25 +895,26 @@ fn prepare_test_runner<'snapshot_ref>( } proc.env( "INSTA_UPDATE", - match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { - (true, _, _) => "no", - (_, true, _) => "unseen", - (_, false, _) => "new", - // Don't yet set `INSTA_UPDATE=force` for - // `--force-update-snapshots`, since this would break with older - // versions of insta. In late 2024, we can swap this code in. - // - // (true, _, false) => "no", - // (_, true, false) => "unseen", - // (_, false, false) => "new", - // (false, false, true) => "force", - // _ => return Err(err_msg(format!("invalid combination of flags: check={}, accept-unseen={}, force-update-snapshots={}", cmd.check, cmd.accept_unseen, cmd.force_update_snapshots))), - }, + if *INSTA_VERSION >= Version::new(1,40,0) { + match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { + // Don't set `INSTA_UPDATE=force` for + // `--force-update-snapshots` on older versions + (true, _, false) => "no", + (_, true, false) => "unseen", + (_, false, false) => "new", + (false, false, true) => "force", + _ => return Err(err_msg(format!("invalid combination of flags: check={}, accept-unseen={}, force-update-snapshots={}", cmd.check, cmd.accept_unseen, cmd.force_update_snapshots))), + } + } else { + match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { + (true, _, _) => "no", + (_, true, _) => "unseen", + (_, false, _) => "new", + } + } ); - if cmd.force_update_snapshots { - // Currently compatible with older versions of insta. In late 2024, we can add: - // proc.env("INSTA_UPDATE", "force"); - // And then eventually we can remove these. + if cmd.force_update_snapshots && *INSTA_VERSION < Version::new(1, 40, 0) { + // Currently compatible with older versions of insta. proc.env("INSTA_FORCE_UPDATE_SNAPSHOTS", "1"); proc.env("INSTA_FORCE_UPDATE", "1"); } diff --git a/cargo-insta/src/utils.rs b/cargo-insta/src/utils.rs index 2d1091a3..9d1af30b 100644 --- a/cargo-insta/src/utils.rs +++ b/cargo-insta/src/utils.rs @@ -1,6 +1,10 @@ use std::error::Error; use std::fmt; +use cargo_metadata::MetadataCommand; +use lazy_static::lazy_static; +use semver::Version; + /// Close without message but exit code. #[derive(Debug)] pub(crate) struct QuietExit(pub(crate) i32); @@ -27,3 +31,19 @@ impl fmt::Display for ErrMsg { pub(crate) fn err_msg>(s: S) -> Box { Box::new(ErrMsg(s.into())) } + +/// The insta version in the current workspace (i.e. not the `cargo-insta` +/// binary that's running). +fn read_insta_version() -> Result> { + MetadataCommand::new() + .exec()? + .packages + .iter() + .find(|package| package.name == "insta") + .map(|package| package.version.clone()) + .ok_or("insta not found in cargo metadata".into()) +} + +lazy_static! { + pub static ref INSTA_VERSION: Version = read_insta_version().unwrap(); +} diff --git a/cargo-insta/tests/main.rs b/cargo-insta/tests/main.rs index 2d6e377b..ae8ab31a 100644 --- a/cargo-insta/tests/main.rs +++ b/cargo-insta/tests/main.rs @@ -12,7 +12,8 @@ /// temporary workspace dirs. (We could try to enforce different names, or give /// up using a consistent target directory for a cache, but it would slow down /// repeatedly running the tests locally. To demonstrate the effect, name crates -/// the same...) +/// the same...). This also causes issues when running the same tests +/// concurrently. use std::collections::HashMap; use std::env; use std::fs; @@ -717,3 +718,105 @@ fn test_virtual_manifest_single_crate() { member-2/src "### ); } + +fn create_test_project(name: &str, insta_dependency: &str) -> TestProject { + TestFiles::new() + .add_file( + "Cargo.toml", + format!( + r#" +[package] +name = "test_force_update_{}" +version = "0.1.0" +edition = "2021" + +[dependencies] +insta = {} +"#, + name, insta_dependency + ) + .to_string(), + ) + .add_file( + "src/lib.rs", + r#" +#[test] +fn test_snapshot_with_newline() { + insta::assert_snapshot!("force_update", "Hello, world!"); +} +"# + .to_string(), + ) + .add_file( + format!( + "src/snapshots/test_force_update_{}__force_update.snap", + name + ), + r#" +--- +source: src/lib.rs +expression: +--- +Hello, world! + + +"# + .to_string(), + ) + .create_project() +} + +#[test] +fn test_force_update_snapshots() { + let test_current_insta = create_test_project("current", "{ path = '$PROJECT_PATH' }"); + let test_insta_1_39_0 = create_test_project("1_39_0", "\"1.39.0\""); + + // Test with current insta version + let output_current = test_current_insta + .cmd() + .args(["test", "--accept", "--force-update-snapshots"]) + .output() + .unwrap(); + + assert_success(&output_current); + + // Test with insta 1.39.0 + let output_1_39_0 = test_insta_1_39_0 + .cmd() + .args(["test", "--accept", "--force-update-snapshots"]) + .output() + .unwrap(); + + assert_success(&output_1_39_0); + + // Check that both versions updated the snapshot correctly + assert_snapshot!(test_current_insta.diff("src/snapshots/test_force_update_current__force_update.snap"), @r#" + --- Original: src/snapshots/test_force_update_current__force_update.snap + +++ Updated: src/snapshots/test_force_update_current__force_update.snap + @@ -1,8 +1,5 @@ + - + --- + source: src/lib.rs + -expression: + +expression: "\"Hello, world!\"" + --- + Hello, world! + - + - + "#); + + assert_snapshot!(test_insta_1_39_0.diff("src/snapshots/test_force_update_1_39_0__force_update.snap"), @r#" + --- Original: src/snapshots/test_force_update_1_39_0__force_update.snap + +++ Updated: src/snapshots/test_force_update_1_39_0__force_update.snap + @@ -1,8 +1,5 @@ + - + --- + source: src/lib.rs + -expression: + +expression: "\"Hello, world!\"" + --- + Hello, world! + - + - + "#); +} diff --git a/insta/Cargo.toml b/insta/Cargo.toml index 5d7ae7d2..f46afdb3 100644 --- a/insta/Cargo.toml +++ b/insta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "insta" -version = "1.39.0" +version = "1.40.0" license = "Apache-2.0" authors = ["Armin Ronacher "] description = "A snapshot testing library for Rust" From 1056bc495fe8d54c8cdca88498a8ee61ca3744c5 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 3 Aug 2024 23:56:11 -0700 Subject: [PATCH 09/21] --- Cargo.lock | 75 +++++++++++++++++++++--------------------- cargo-insta/Cargo.toml | 8 ++--- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1f84827..59e5054b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,12 +52,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", - "regex-automata 0.4.7", + "regex-automata 0.3.0", "serde", ] @@ -185,25 +185,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.20" @@ -308,9 +289,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", - "bstr 1.10.0", + "bstr 1.6.2", "log", - "regex-automata 0.4.7", + "regex-automata 0.4.0", "regex-syntax", ] @@ -328,16 +309,18 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "ignore" -version = "0.4.22" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" dependencies = [ - "crossbeam-deque", + "crossbeam-utils", "globset", + "lazy_static", "log", "memchr", - "regex-automata 0.4.7", + "regex", "same-file", + "thread_local", "walkdir", "winapi-util", ] @@ -398,9 +381,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lazy_static" -version = "1.5.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" @@ -503,13 +486,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.0", "regex-syntax", ] @@ -521,9 +504,15 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa250384981ea14565685dea16a9ccc4d1c541a13f82b9c168572264d1df8c56" + +[[package]] +name = "regex-automata" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "5d58da636bd923eae52b7e9120271cbefb16f399069ee566ca5ebf9c30e32238" dependencies = [ "aho-corasick", "memchr", @@ -532,9 +521,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" [[package]] name = "ron" @@ -641,7 +630,7 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" dependencies = [ - "bstr 1.10.0", + "bstr 1.6.2", "unicode-segmentation", ] @@ -714,6 +703,16 @@ dependencies = [ "syn", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "toml" version = "0.5.11" diff --git a/cargo-insta/Cargo.toml b/cargo-insta/Cargo.toml index fce4a6ca..b5c04afc 100644 --- a/cargo-insta/Cargo.toml +++ b/cargo-insta/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["snapshot", "testing", "jest"] categories = ["development-tools::cargo-plugins"] edition = "2018" readme = "README.md" -rust-version = "1.64.0" +rust-version = "1.65.0" [dependencies] insta = { version = "=1.40.0", path = "../insta", features = ["json", "yaml", "redactions", "_cargo_insta_internal"] } @@ -22,17 +22,17 @@ serde_json = "1.0.59" proc-macro2 = { version = "1.0.60", features = ["span-locations"] } # Pinned because of MSRV; wait for MSRV bump or msrv-resolver syn = { version = "=2.0.8", features = ["full", "visit", "extra-traits"] } -ignore = "0.4.17" +# Pinned because of MSRV; wait for MSRV bump or msrv-resolver +ignore = "=0.4.17" uuid = { version = "1.0.0", features = ["v4"] } tempfile = "3.5.0" # Pinned because of MSRV; wait for MSRV bump or msrv-resolver semver = {version = "=1.0.7", features = ["serde"]} -lazy_static = "1.4.0" +lazy_static = "=1.4.0" # Not yet supported in our MSRV of 1.60.0 # clap = { workspace=true } clap = {version = "=4.1", features = ["derive", "env"]} - [dev-dependencies] walkdir = "2.3.1" similar= "2.2.1" From 0aab8b76b8d9acdb65c59a93a5e81fe92d86fa07 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 4 Aug 2024 02:05:49 -0700 Subject: [PATCH 10/21] --- cargo-insta/src/cli.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index fdab6766..43f6e6ba 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -895,21 +895,21 @@ fn prepare_test_runner<'snapshot_ref>( } proc.env( "INSTA_UPDATE", + // Don't set `INSTA_UPDATE=force` for `--force-update-snapshots` on + // older versions if *INSTA_VERSION >= Version::new(1,40,0) { match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { - // Don't set `INSTA_UPDATE=force` for - // `--force-update-snapshots` on older versions - (true, _, false) => "no", - (_, true, false) => "unseen", - (_, false, false) => "new", - (false, false, true) => "force", + (true, false, false) => "no", + (false, true, false) => "unseen", + (false, false, false) => "new", + (false, _, true) => "force", _ => return Err(err_msg(format!("invalid combination of flags: check={}, accept-unseen={}, force-update-snapshots={}", cmd.check, cmd.accept_unseen, cmd.force_update_snapshots))), } } else { - match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { - (true, _, _) => "no", - (_, true, _) => "unseen", - (_, false, _) => "new", + match (cmd.check, cmd.accept_unseen) { + (true, _) => "no", + (_, true) => "unseen", + (_, false) => "new", } } ); From d5d1ab74adcf780059ed35910e4f600f4d376f91 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 4 Aug 2024 14:22:29 -0700 Subject: [PATCH 11/21] Make the deprecation warning logic clearer --- insta/src/env.rs | 50 +++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/insta/src/env.rs b/insta/src/env.rs index ef298b5d..4ace61ec 100644 --- a/insta/src/env.rs +++ b/insta/src/env.rs @@ -146,33 +146,35 @@ impl ToolConfig { // Support for the deprecated environment variables. This is // implemented in a way that cargo-insta can support older and newer - // insta versions alike. `cargo-insta` will currently set - // `INSTA_FORCE_UPDATE_SNAPSHOTS` & `INSTA_FORCE_UPDATE`, and in late - // 2024 will set `INSTA_UPDATE=force` (this would break older versions - // of insta if we implemented immediately). + // insta versions alike. Versions of `cargo-insta` <= 1.39 will set + // `INSTA_FORCE_UPDATE_SNAPSHOTS` & `INSTA_FORCE_UPDATE`. // // If `INSTA_FORCE_UPDATE_SNAPSHOTS` is the only env var present we emit // a deprecation warning, later to be expanded to `INSTA_FORCE_UPDATE`. - if env::var("INSTA_UPDATE").is_err() { - let mut force_update = false; - if let Ok("1") = env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").as_deref() { - eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_UPDATE=force"); - force_update = true; - } - if let Ok("1") = env::var("INSTA_FORCE_UPDATE").as_deref() { - // Don't raise a warning yet, because `cargo-insta` still uses - // this, so that it's compatible with older versions of `insta`. - // In the future, switch `cargo-insta` to use - // `INSTA_UPDATE=force`, and raise a warning for - // `INSTA_FORCE_UPDATE`. - // - // eprintln!("INSTA_FORCE_UPDATE is deprecated, use - // INSTA_UPDATE=force"); - force_update = true; - } - if force_update { - env::set_var("INSTA_UPDATE", "force"); - } + // + // Another approach would be to pass the version of `cargo-insta` in a + // `INSTA_CARGO_INSTA_VERSION` env var, and then raise a warning unless + // running under cargo-insta <= 1.39. Though it would require adding a + // `semver` dependency to this crate or doing the version comparison + // ourselves (a tractable task...). + let force_update_old_env_vars = if let Ok("1") = env::var("INSTA_FORCE_UPDATE").as_deref() { + // Don't raise a warning yet, because recent versions of + // `cargo-insta` use this, so that it's compatible with older + // versions of `insta`. + // + // eprintln!("INSTA_FORCE_UPDATE is deprecated, use + // INSTA_UPDATE=force"); + true + } else if let Ok("1") = env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").as_deref() { + // Do we need to log with a stronger output than `eprintln` to + // escape the cargo test capturing? + eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_UPDATE=force"); + true + } else { + false + }; + if force_update_old_env_vars { + env::set_var("INSTA_UPDATE", "force"); } Ok(ToolConfig { From 7c895b3036235447bd601056119124cf844e7f38 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 4 Aug 2024 20:45:55 -0700 Subject: [PATCH 12/21] . --- insta/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/insta/src/lib.rs b/insta/src/lib.rs index eb805c74..d841f2bc 100644 --- a/insta/src/lib.rs +++ b/insta/src/lib.rs @@ -208,8 +208,6 @@ //! //! ```yaml //! behavior: -//! # also set by INSTA_FORCE_UPDATE -//! force_update: true/false //! # also set by INSTA_REQUIRE_FULL_MATCH //! require_full_match: true/false //! # also set by INSTA_FORCE_PASS From d23a66635b0e4a26117b622a7496f7be0c1575e2 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 5 Aug 2024 10:20:12 -0700 Subject: [PATCH 13/21] Use elog rather than eprint to get past cargo test filter --- insta/Cargo.toml | 2 +- insta/src/env.rs | 19 +++++++++++++------ insta/src/runtime.rs | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/insta/Cargo.toml b/insta/Cargo.toml index f46afdb3..cca60ea2 100644 --- a/insta/Cargo.toml +++ b/insta/Cargo.toml @@ -37,7 +37,7 @@ colors = ["console"] # Serialization formats # TODO: This could be cleaner by using "dep:csv" without renaming the dep, but -# this technique allows for a lower MSRV +# `dep_csv` allows for a lower MSRV csv = ["dep_csv", "serde"] json = ["serde"] ron = ["dep_ron", "serde"] diff --git a/insta/src/env.rs b/insta/src/env.rs index 4ace61ec..93a188f9 100644 --- a/insta/src/env.rs +++ b/insta/src/env.rs @@ -4,8 +4,11 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use std::{env, fmt, fs}; -use crate::content::{yaml, Content}; use crate::utils::is_ci; +use crate::{ + content::{yaml, Content}, + elog, +}; lazy_static::lazy_static! { static ref WORKSPACES: Mutex>> = Mutex::new(BTreeMap::new()); @@ -162,13 +165,17 @@ impl ToolConfig { // `cargo-insta` use this, so that it's compatible with older // versions of `insta`. // - // eprintln!("INSTA_FORCE_UPDATE is deprecated, use + // elog!("INSTA_FORCE_UPDATE is deprecated, use // INSTA_UPDATE=force"); true } else if let Ok("1") = env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").as_deref() { - // Do we need to log with a stronger output than `eprintln` to - // escape the cargo test capturing? - eprintln!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_UPDATE=force"); + // Warn on an old envvar. + // + // There's some possibility that we're running from within an fairly + // old version of `cargo-insta` (before we added an + // `INSTA_CARGO_INSTA` env var, so we can't pick that up.) So offer + // a caveat in that case. + elog!("INSTA_FORCE_UPDATE_SNAPSHOTS is deprecated, use INSTA_UPDATE=force. (If running from `cargo insta`, no action is required; upgrading `cargo-insta` will silence this warning.)"); true } else { false @@ -217,7 +224,7 @@ impl ToolConfig { .and_then(|x| x.as_str()) // Legacy support for the old force update config .or(resolve(&cfg, &["behavior", "force_update"]).and_then(|x| { - eprintln!("`force_update: true` is deprecated, use `update: force`"); + elog!("`force_update: true` is deprecated in insta config files, use `update: force`"); match x.as_bool() { Some(true) => Some("force"), _ => None, diff --git a/insta/src/runtime.rs b/insta/src/runtime.rs index 3fa3c7e1..914dede9 100644 --- a/insta/src/runtime.rs +++ b/insta/src/runtime.rs @@ -32,6 +32,7 @@ thread_local! { // This macro is basically eprintln but without being captured and // hidden by the test runner. +#[macro_export] macro_rules! elog { () => (write!(std::io::stderr()).ok()); ($($arg:tt)*) => ({ From 4e73070f78862b3e10485040af662f073d73c140 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 5 Aug 2024 20:56:12 -0700 Subject: [PATCH 14/21] . --- Cargo.toml | 2 +- cargo-insta/Cargo.toml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc50bca1..d38d0655 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,5 @@ inherits = "release" lto = "thin" [workspace.dependencies] -# Locking because of MSRV; wait for MSRV bump or msrv-resolver +# Needs pinning in Cargo.lock because of MSRV clap = {version = "4.1", features = ["derive", "env"]} diff --git a/cargo-insta/Cargo.toml b/cargo-insta/Cargo.toml index 1f913ff5..3e0de6c4 100644 --- a/cargo-insta/Cargo.toml +++ b/cargo-insta/Cargo.toml @@ -20,17 +20,17 @@ console = "0.15.4" serde = { version = "1.0.117", features = ["derive"] } serde_json = "1.0.59" proc-macro2 = { version = "1.0.60", features = ["span-locations"] } -# Pinned because of MSRV; wait for MSRV bump or msrv-resolver +# Needs pinning in Cargo.lock because of MSRV syn = { version = "2.0.8", features = ["full", "visit", "extra-traits"] } +# Needs pinning in Cargo.lock because of MSRV ignore = "0.4.17" uuid = { version = "1.0.0", features = ["v4"] } tempfile = "3.5.0" -# Pinned because of MSRV; wait for MSRV bump or msrv-resolver -semver = {version = "=1.0.7", features = ["serde"]} -lazy_static = "=1.4.0" +# Needs pinning in Cargo.lock because of MSRV +semver = {version = "1.0.7", features = ["serde"]} +lazy_static = "1.4.0" # Not yet supported in our MSRV of 1.60.0 -# clap = { workspace=true } -clap = {version = "4.1", features = ["derive", "env"]} +clap = { workspace=true } [dev-dependencies] walkdir = "2.3.1" From a4c3b0c2223c5f2586a7c579e00160d8fcd367d7 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Tue, 6 Aug 2024 10:42:02 -0700 Subject: [PATCH 15/21] --- cargo-insta/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/cargo-insta/Cargo.toml b/cargo-insta/Cargo.toml index 3e0de6c4..14f3b28a 100644 --- a/cargo-insta/Cargo.toml +++ b/cargo-insta/Cargo.toml @@ -29,7 +29,6 @@ tempfile = "3.5.0" # Needs pinning in Cargo.lock because of MSRV semver = {version = "1.0.7", features = ["serde"]} lazy_static = "1.4.0" -# Not yet supported in our MSRV of 1.60.0 clap = { workspace=true } [dev-dependencies] From 1d20e59b5be5fbcb9a4bc16d90b29aa304ed4deb Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 8 Aug 2024 21:34:35 -0700 Subject: [PATCH 16/21] --- Cargo.lock | 449 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 327 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59e5054b..a4d48993 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] @@ -23,17 +23,11 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - [[package]] name = "block-buffer" -version = "0.10.4" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] @@ -52,20 +46,20 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.2" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.3.0", + "regex-automata 0.4.7", "serde", ] [[package]] name = "camino" -version = "1.1.7" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] @@ -103,9 +97,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.18.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +checksum = "fb9ac64500cc83ce4b9f8dafa78186aa008c8dea77a09b94cd307fd0cd5022a8" dependencies = [ "camino", "cargo-platform", @@ -115,6 +109,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + [[package]] name = "cfg-if" version = "1.0.0" @@ -138,7 +138,7 @@ version = "4.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "351f9ad9688141ed83dfd8f5fb998a06225ef444b48ff4dc43de6d409b7fd10b" dependencies = [ - "bitflags 1.3.2", + "bitflags", "clap_lex", "is-terminal", "strsim", @@ -165,31 +165,35 @@ checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "console" -version = "0.15.8" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "c9b6515d269224923b26b5febea2ed42b2d5f2ce37284a4dd670fedd6cb8347a" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.52.0", + "windows-sys 0.42.0", ] [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" dependencies = [ "libc", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +dependencies = [ + "cfg-if", + "once_cell", +] [[package]] name = "crypto-common" @@ -247,25 +251,45 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", "libc", - "windows-sys 0.52.0", ] [[package]] name = "fastrand" -version = "2.1.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -273,9 +297,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", @@ -284,15 +308,15 @@ dependencies = [ [[package]] name = "globset" -version = "0.4.14" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" dependencies = [ "aho-corasick", - "bstr 1.6.2", + "bstr 0.2.17", + "fnv", "log", - "regex-automata 0.4.0", - "regex-syntax", + "regex", ] [[package]] @@ -303,15 +327,15 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "ignore" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" +checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" dependencies = [ "crossbeam-utils", "globset", @@ -347,6 +371,26 @@ dependencies = [ "walkdir", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "is-terminal" version = "0.4.12" @@ -375,9 +419,9 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "lazy_static" @@ -387,9 +431,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "linked-hash-map" @@ -399,15 +443,18 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "log" -version = "0.4.22" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] [[package]] name = "memchr" @@ -417,9 +464,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" -version = "1.19.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" [[package]] name = "pest" @@ -484,15 +531,23 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" -version = "1.10.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.0", "regex-syntax", ] @@ -504,26 +559,15 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-automata" -version = "0.3.0" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa250384981ea14565685dea16a9ccc4d1c541a13f82b9c168572264d1df8c56" - -[[package]] -name = "regex-automata" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d58da636bd923eae52b7e9120271cbefb16f399069ee566ca5ebf9c30e32238" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" [[package]] name = "regex-syntax" -version = "0.8.0" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "ron" @@ -532,7 +576,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" dependencies = [ "base64", - "bitflags 1.3.2", + "bitflags", "serde", ] @@ -547,22 +591,23 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", + "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.48.0", ] [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "same-file" @@ -575,9 +620,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.7" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" dependencies = [ "serde", ] @@ -604,11 +649,11 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" dependencies = [ - "itoa 1.0.11", + "itoa 1.0.3", "ryu", "serde", ] @@ -630,7 +675,7 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" dependencies = [ - "bstr 1.6.2", + "bstr 1.10.0", "unicode-segmentation", ] @@ -663,15 +708,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.11.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "once_cell", + "redox_syscall", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.45.0", ] [[package]] @@ -705,11 +750,10 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" dependencies = [ - "cfg-if", "once_cell", ] @@ -724,56 +768,57 @@ dependencies = [ [[package]] name = "typenum" -version = "1.17.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "uuid" -version = "1.10.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" dependencies = [ "getrandom", ] [[package]] name = "version_check" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" -version = "2.5.0" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", + "winapi", "winapi-util", ] @@ -783,13 +828,68 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-sys 0.59.0", + "windows-targets 0.48.0", ] [[package]] @@ -798,16 +898,37 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] -name = "windows-sys" -version = "0.59.0" +name = "windows-targets" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows-targets", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -816,28 +937,64 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -850,24 +1007,72 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" From beb2c58e5252e5564c5fae8db3d338cc1c5459bf Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 31 Aug 2024 15:26:30 -0700 Subject: [PATCH 17/21] make inline snapshots work with the new `force` --- cargo-insta/tests/main.rs | 16 +++++++++++++--- insta/src/runtime.rs | 24 ++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/cargo-insta/tests/main.rs b/cargo-insta/tests/main.rs index eb3c0199..82e33aaf 100644 --- a/cargo-insta/tests/main.rs +++ b/cargo-insta/tests/main.rs @@ -112,15 +112,25 @@ impl TestProject { } fn cmd(&self) -> Command { let mut command = Command::new(env!("CARGO_BIN_EXE_cargo-insta")); + // Remove environment variables so we don't inherit anything (such as + // `CI` or `INSTA_FORCE_PASS` or `CARGO_INSTA_*`) from a cargo-insta process which runs + // this test. + // for var in command.e + command.env_clear(); + + command.env("PATH", env::var("PATH").unwrap()); + + // Turn off CI flag so that cargo insta test behaves as we expect + // under normal operation + command.env("CI", "0"); + command.current_dir(self.workspace_dir.as_path()); // Use the same target directory as other tests, consistent across test // run. This makes the compilation much faster (though do some tests // tread on the toes of others? We could have a different cache for each // project if so...) command.env("CARGO_TARGET_DIR", target_dir()); - // Turn off CI flag so that cargo insta test behaves as we expect - // under normal operation - command.env("CI", "0"); + command } diff --git a/insta/src/runtime.rs b/insta/src/runtime.rs index 88372fda..6a63d6be 100644 --- a/insta/src/runtime.rs +++ b/insta/src/runtime.rs @@ -369,6 +369,17 @@ impl<'a> SnapshotAssertionContext<'a> { let should_print = self.tool_config.output_behavior() != OutputBehavior::Nothing; let snapshot_update = snapshot_update_behavior(&self.tool_config, unseen); + // If snapshot_update is `InPlace` and we have an inline snapshot, then + // use `NewFile`, since we can't use `InPlace` for inline. `cargo-insta` + // then accepts all snapshots at the end of the test. + + let snapshot_update = + if snapshot_update == SnapshotUpdateBehavior::InPlace && self.snapshot_file.is_none() { + SnapshotUpdateBehavior::NewFile + } else { + snapshot_update + }; + match snapshot_update { SnapshotUpdateBehavior::InPlace => { if let Some(ref snapshot_file) = self.snapshot_file { @@ -384,16 +395,9 @@ impl<'a> SnapshotAssertionContext<'a> { style(snapshot_file.display()).cyan().underlined(), ); } - } else if should_print { - elog!( - "{}", - style( - "error: cannot update inline snapshots in-place \ - (https://github.com/mitsuhiko/insta/issues/272)" - ) - .red() - .bold(), - ); + } else { + // Checked self.snapshot_file.is_none() above + unreachable!() } } SnapshotUpdateBehavior::NewFile => { From eb92ef4763b013ad06b027700596078200e3fd3d Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 31 Aug 2024 15:28:15 -0700 Subject: [PATCH 18/21] --- cargo-insta/tests/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cargo-insta/tests/main.rs b/cargo-insta/tests/main.rs index 82e33aaf..33093025 100644 --- a/cargo-insta/tests/main.rs +++ b/cargo-insta/tests/main.rs @@ -114,14 +114,13 @@ impl TestProject { let mut command = Command::new(env!("CARGO_BIN_EXE_cargo-insta")); // Remove environment variables so we don't inherit anything (such as // `CI` or `INSTA_FORCE_PASS` or `CARGO_INSTA_*`) from a cargo-insta process which runs - // this test. - // for var in command.e + // this test. We could iterate through the current `env` if we find this + // removes too many. command.env_clear(); - command.env("PATH", env::var("PATH").unwrap()); // Turn off CI flag so that cargo insta test behaves as we expect - // under normal operation + // under normal operation (likely unneeded given the above, could remove) command.env("CI", "0"); command.current_dir(self.workspace_dir.as_path()); From 35b6321b19e9935ebb2408c63f3536ae78c501ca Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sat, 31 Aug 2024 15:36:14 -0700 Subject: [PATCH 19/21] --- cargo-insta/tests/main.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cargo-insta/tests/main.rs b/cargo-insta/tests/main.rs index 33093025..69d8ca34 100644 --- a/cargo-insta/tests/main.rs +++ b/cargo-insta/tests/main.rs @@ -114,10 +114,13 @@ impl TestProject { let mut command = Command::new(env!("CARGO_BIN_EXE_cargo-insta")); // Remove environment variables so we don't inherit anything (such as // `CI` or `INSTA_FORCE_PASS` or `CARGO_INSTA_*`) from a cargo-insta process which runs - // this test. We could iterate through the current `env` if we find this - // removes too many. - command.env_clear(); - command.env("PATH", env::var("PATH").unwrap()); + // this test. + for (key, _) in env::vars() { + // Remove variables that start with "CARGO_INSTA" or "INSTA" + if key.starts_with("CARGO_INSTA") || key.starts_with("INSTA") { + command.env_remove(&key); + } + } // Turn off CI flag so that cargo insta test behaves as we expect // under normal operation (likely unneeded given the above, could remove) From cdff50d2a84f5c5f5352e3a257e7ee9a82f03ce8 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 1 Sep 2024 16:16:58 -0700 Subject: [PATCH 20/21] Add integration test for force updating From https://github.com/mitsuhiko/insta/pull/482 --- cargo-insta/tests/main.rs | 112 +++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/cargo-insta/tests/main.rs b/cargo-insta/tests/main.rs index 71f4a7fe..34408692 100644 --- a/cargo-insta/tests/main.rs +++ b/cargo-insta/tests/main.rs @@ -12,7 +12,8 @@ /// temporary workspace dirs. (We could try to enforce different names, or give /// up using a consistent target directory for a cache, but it would slow down /// repeatedly running the tests locally. To demonstrate the effect, name crates -/// the same...) +/// the same...). This also causes issues when running the same tests +/// concurrently. use std::collections::HashMap; use std::env; use std::fs; @@ -716,6 +717,115 @@ fn test_virtual_manifest_single_crate() { "### ); } +#[test] +fn test_force_update_snapshots() { + // We test with both 1.39 and `master`. These currently test the same code! + // But I copied the test from + // https://github.com/mitsuhiko/insta/pull/482/files where they'll test + // different code. If we don't end up merging that, we can remove one of the + // tests (but didn't think it was worthwhile to do the work to then undo it) + + fn create_test_force_update_project(name: &str, insta_dependency: &str) -> TestProject { + TestFiles::new() + .add_file( + "Cargo.toml", + format!( + r#" +[package] +name = "test_force_update_{}" +version = "0.1.0" +edition = "2021" + +[dependencies] +insta = {} +"#, + name, insta_dependency + ) + .to_string(), + ) + .add_file( + "src/lib.rs", + r#" +#[test] +fn test_snapshot_with_newline() { + insta::assert_snapshot!("force_update", "Hello, world!"); +} +"# + .to_string(), + ) + .add_file( + format!( + "src/snapshots/test_force_update_{}__force_update.snap", + name + ), + r#" +--- +source: src/lib.rs +expression: +--- +Hello, world! + + +"# + .to_string(), + ) + .create_project() + } + + let test_current_insta = + create_test_force_update_project("current", "{ path = '$PROJECT_PATH' }"); + let test_insta_1_39_0 = create_test_force_update_project("1_39_0", "\"1.39.0\""); + + // Test with current insta version + let output_current = test_current_insta + .cmd() + .args(["test", "--accept", "--force-update-snapshots"]) + .output() + .unwrap(); + + assert_success(&output_current); + + // Test with insta 1.39.0 + let output_1_39_0 = test_insta_1_39_0 + .cmd() + .args(["test", "--accept", "--force-update-snapshots"]) + .output() + .unwrap(); + + assert_success(&output_1_39_0); + + // Check that both versions updated the snapshot correctly + assert_snapshot!(test_current_insta.diff("src/snapshots/test_force_update_current__force_update.snap"), @r#" + --- Original: src/snapshots/test_force_update_current__force_update.snap + +++ Updated: src/snapshots/test_force_update_current__force_update.snap + @@ -1,8 +1,5 @@ + - + --- + source: src/lib.rs + -expression: + +expression: "\"Hello, world!\"" + --- + Hello, world! + - + - + "#); + + assert_snapshot!(test_insta_1_39_0.diff("src/snapshots/test_force_update_1_39_0__force_update.snap"), @r#" + --- Original: src/snapshots/test_force_update_1_39_0__force_update.snap + +++ Updated: src/snapshots/test_force_update_1_39_0__force_update.snap + @@ -1,8 +1,5 @@ + - + --- + source: src/lib.rs + -expression: + +expression: "\"Hello, world!\"" + --- + Hello, world! + - + - + "#); +} + #[test] fn test_force_update_inline_snapshot() { let test_project = TestFiles::new() From 2341f0dcc7832e46bbfa3da4c8ac8185e09befc9 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 8 Sep 2024 11:04:21 -0700 Subject: [PATCH 21/21] missed release so bump versions --- Cargo.lock | 4 ++-- cargo-insta/Cargo.toml | 4 ++-- cargo-insta/src/cli.rs | 2 +- cargo-insta/tests/main.rs | 14 +++++++------- insta/Cargo.toml | 2 +- insta/src/snapshot.rs | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4d48993..097fba72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "cargo-insta" -version = "1.40.0" +version = "1.41.0" dependencies = [ "cargo_metadata", "clap", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "insta" -version = "1.40.0" +version = "1.41.0" dependencies = [ "clap", "console", diff --git a/cargo-insta/Cargo.toml b/cargo-insta/Cargo.toml index 5e43bbbb..9e95c6fd 100644 --- a/cargo-insta/Cargo.toml +++ b/cargo-insta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-insta" -version = "1.40.0" +version = "1.41.0" license = "Apache-2.0" authors = ["Armin Ronacher "] description = "A review tool for the insta snapshot testing library for Rust" @@ -14,7 +14,7 @@ readme = "README.md" rust-version = "1.65.0" [dependencies] -insta = { version = "=1.40.0", path = "../insta", features = ["json", "yaml", "redactions", "_cargo_insta_internal"] } +insta = { version = "=1.41.0", path = "../insta", features = ["json", "yaml", "redactions", "_cargo_insta_internal"] } cargo_metadata = { version = "0.18.0", default-features = false } console = "0.15.4" serde = { version = "1.0.117", features = ["derive"] } diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 51d9385b..295cdaf5 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -950,7 +950,7 @@ fn prepare_test_runner<'snapshot_ref>( "INSTA_UPDATE", // Don't set `INSTA_UPDATE=force` for `--force-update-snapshots` on // older versions - if *INSTA_VERSION >= Version::new(1,40,0) { + if *INSTA_VERSION >= Version::new(1,41,0) { match (cmd.check, cmd.accept_unseen, cmd.force_update_snapshots) { (true, false, false) => "no", (false, true, false) => "unseen", diff --git a/cargo-insta/tests/main.rs b/cargo-insta/tests/main.rs index fc2365f8..57708511 100644 --- a/cargo-insta/tests/main.rs +++ b/cargo-insta/tests/main.rs @@ -778,7 +778,7 @@ Hello, world! let test_current_insta = create_test_force_update_project("current", "{ path = '$PROJECT_PATH' }"); - let test_insta_1_39_0 = create_test_force_update_project("1_39_0", "\"1.39.0\""); + let test_insta_1_40_0 = create_test_force_update_project("1_40_0", "\"1.40.0\""); // Test with current insta version let output_current = test_current_insta @@ -789,14 +789,14 @@ Hello, world! assert_success(&output_current); - // Test with insta 1.39.0 - let output_1_39_0 = test_insta_1_39_0 + // Test with insta 1.40.0 + let output_1_40_0 = test_insta_1_40_0 .cmd() .args(["test", "--accept", "--force-update-snapshots"]) .output() .unwrap(); - assert_success(&output_1_39_0); + assert_success(&output_1_40_0); // Check that both versions updated the snapshot correctly assert_snapshot!(test_current_insta.diff("src/snapshots/test_force_update_current__force_update.snap"), @r#" @@ -814,9 +814,9 @@ Hello, world! - "#); - assert_snapshot!(test_insta_1_39_0.diff("src/snapshots/test_force_update_1_39_0__force_update.snap"), @r#" - --- Original: src/snapshots/test_force_update_1_39_0__force_update.snap - +++ Updated: src/snapshots/test_force_update_1_39_0__force_update.snap + assert_snapshot!(test_insta_1_40_0.diff("src/snapshots/test_force_update_1_40_0__force_update.snap"), @r#" + --- Original: src/snapshots/test_force_update_1_40_0__force_update.snap + +++ Updated: src/snapshots/test_force_update_1_40_0__force_update.snap @@ -1,8 +1,5 @@ - --- diff --git a/insta/Cargo.toml b/insta/Cargo.toml index 5df915f0..6759e9a3 100644 --- a/insta/Cargo.toml +++ b/insta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "insta" -version = "1.40.0" +version = "1.41.0" license = "Apache-2.0" authors = ["Armin Ronacher "] description = "A snapshot testing library for Rust" diff --git a/insta/src/snapshot.rs b/insta/src/snapshot.rs index 8c8fafe4..d81c26ef 100644 --- a/insta/src/snapshot.rs +++ b/insta/src/snapshot.rs @@ -319,7 +319,7 @@ impl Snapshot { } } } - eprintln!("A snapshot uses an old snapshot format; please update it to the new format with `cargo insta --force-update-snapshots.\n\nSnapshot is at: {}", p.to_string_lossy()); + crate::elog!("A snapshot uses an old snapshot format; please update it to the new format with `cargo insta test --force-update-snapshots --accept`.\n\nSnapshot is at: {}", p.to_string_lossy()); rv }; @@ -717,7 +717,7 @@ fn get_inline_snapshot_value(frozen_value: &str) -> String { // (the only call site) if frozen_value.trim_start().starts_with('⋮') { - eprintln!("A snapshot uses an old snapshot format; please update it to the new format with `cargo insta --force-update-snapshots.\n\nValue: {}", frozen_value); + crate::elog!("A snapshot uses an old snapshot format; please update it to the new format with `cargo insta test --force-update-snapshots --accept`.\n\nSnapshot is at: {}", frozen_value); // legacy format - retain so old snapshots still work let mut buf = String::new();