diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9a95a8fe..fd2c71ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,7 @@ env: CARGO_TERM_COLOR: always CLICOLOR_FORCE: 1 RUSTDOCFLAGS: "-Dwarnings" + RUSTFLAGS: "-D warnings" jobs: test-latest: diff --git a/cargo-insta/tests/functional/inline.rs b/cargo-insta/tests/functional/inline.rs index 26579121..8a58679a 100644 --- a/cargo-insta/tests/functional/inline.rs +++ b/cargo-insta/tests/functional/inline.rs @@ -24,6 +24,7 @@ serde = { version = "1.0", features = ["derive"] } r#" use serde::Serialize; +#[allow(dead_code)] #[derive(Serialize)] struct User { id: u64, @@ -56,7 +57,7 @@ fn test_json_snapshot() { assert_snapshot!(test_project.diff("src/lib.rs"), @r##" --- Original: src/lib.rs +++ Updated: src/lib.rs - @@ -15,5 +15,10 @@ + @@ -16,5 +16,10 @@ }; insta::assert_json_snapshot!(&user, { ".id" => "[user_id]", @@ -93,6 +94,7 @@ serde = { version = "1.0", features = ["derive"] } r#" use serde::Serialize; +#[allow(dead_code)] #[derive(Serialize)] struct User { id: u64, @@ -122,10 +124,10 @@ fn test_yaml_snapshot() { assert!(&output.status.success()); - assert_snapshot!(test_project.diff("src/lib.rs"), @r###" + assert_snapshot!(test_project.diff("src/lib.rs"), @r##" --- Original: src/lib.rs +++ Updated: src/lib.rs - @@ -15,5 +15,8 @@ + @@ -16,5 +16,8 @@ }; insta::assert_yaml_snapshot!(&user, { ".id" => "[user_id]", @@ -135,7 +137,7 @@ fn test_yaml_snapshot() { + email: john.doe@example.com + "#); } - "###); + "##); } #[test] diff --git a/insta/src/env.rs b/insta/src/env.rs index 3d59f3fb..565c194b 100644 --- a/insta/src/env.rs +++ b/insta/src/env.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use std::{env, fmt, fs}; -use crate::utils::{get_cargo, is_ci}; +use crate::utils::is_ci; use crate::{ content::{yaml, Content}, elog, @@ -42,6 +42,7 @@ impl TestRunner { /// Fall back to `cargo test` if `cargo nextest` isn't installed and /// `test_runner_fallback` is true pub fn resolve_fallback(&self, test_runner_fallback: bool) -> &TestRunner { + use crate::utils::get_cargo; if self == &TestRunner::Nextest && test_runner_fallback && std::process::Command::new(get_cargo()) diff --git a/insta/src/utils.rs b/insta/src/utils.rs index 8ee58b14..f800252e 100644 --- a/insta/src/utils.rs +++ b/insta/src/utils.rs @@ -108,6 +108,7 @@ pub fn format_rust_expression(value: &str) -> Cow<'_, str> { Cow::Borrowed(value) } +#[cfg(feature = "_cargo_insta_internal")] pub fn get_cargo() -> std::ffi::OsString { let cargo = env::var_os("CARGO"); let cargo = cargo