Skip to content

Commit

Permalink
Fix warning, make them errors in CI (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty authored Dec 12, 2024
1 parent 0cb039d commit f2783e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
CARGO_TERM_COLOR: always
CLICOLOR_FORCE: 1
RUSTDOCFLAGS: "-Dwarnings"
RUSTFLAGS: "-D warnings"

jobs:
test-latest:
Expand Down
10 changes: 6 additions & 4 deletions cargo-insta/tests/functional/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ serde = { version = "1.0", features = ["derive"] }
r#"
use serde::Serialize;
#[allow(dead_code)]
#[derive(Serialize)]
struct User {
id: u64,
Expand Down Expand Up @@ -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]",
Expand Down Expand Up @@ -93,6 +94,7 @@ serde = { version = "1.0", features = ["derive"] }
r#"
use serde::Serialize;
#[allow(dead_code)]
#[derive(Serialize)]
struct User {
id: u64,
Expand Down Expand Up @@ -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]",
Expand All @@ -135,7 +137,7 @@ fn test_yaml_snapshot() {
+ email: [email protected]
+ "#);
}
"###);
"##);
}

#[test]
Expand Down
3 changes: 2 additions & 1 deletion insta/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions insta/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2783e5

Please sign in to comment.