tests(fix): Snapshot fixes

This commit is contained in:
Ed Page 2024-06-05 11:59:50 -05:00
parent a9ee3e82b5
commit c009b3208d

View File

@ -1297,9 +1297,9 @@ fn fix_to_broken_code() {
.with_stderr_contains("[WARNING] failed to automatically apply fixes [..]") .with_stderr_contains("[WARNING] failed to automatically apply fixes [..]")
.run(); .run();
assert_eq!( assert_e2e().eq(
p.read_file("bar/src/lib.rs"), p.read_file("bar/src/lib.rs"),
"pub fn foo() { let x = 3; let _ = x; }" str!["pub fn foo() { let x = 3; let _ = x; }"],
); );
} }
@ -1320,7 +1320,10 @@ fn fix_with_common() {
p.cargo("fix --edition --allow-no-vcs").run(); p.cargo("fix --edition --allow-no-vcs").run();
assert_eq!(p.read_file("tests/common/mod.rs"), "pub fn r#try() {}"); assert_e2e().eq(
p.read_file("tests/common/mod.rs"),
str!["pub fn r#try() {}"],
);
} }
#[cargo_test] #[cargo_test]
@ -2312,9 +2315,10 @@ edition = "2021"
", ",
) )
.run(); .run();
assert_eq!( assert_e2e().eq(
p.read_file("Cargo.toml"), p.read_file("Cargo.toml"),
r#" str![[r#"
cargo-features = ["edition2024"] cargo-features = ["edition2024"]
# Before project # Before project
@ -2323,7 +2327,8 @@ cargo-features = ["edition2024"]
name = "foo" name = "foo"
edition = "2021" edition = "2021"
# After project table # After project table
"#
"#]],
); );
} }
@ -2365,9 +2370,10 @@ edition = "2021"
", ",
) )
.run(); .run();
assert_eq!( assert_e2e().eq(
p.read_file("Cargo.toml"), p.read_file("Cargo.toml"),
r#" str![[r#"
cargo-features = ["edition2024"] cargo-features = ["edition2024"]
# Before package # Before package
@ -2376,7 +2382,8 @@ cargo-features = ["edition2024"]
name = "foo" name = "foo"
edition = "2021" edition = "2021"
# After project table # After project table
"#
"#]],
); );
} }
@ -2469,9 +2476,10 @@ a = {path = "a", default_features = false}
", ",
) )
.run(); .run();
assert_eq!( assert_e2e().eq(
p.read_file("Cargo.toml"), p.read_file("Cargo.toml"),
r#" str![[r#"
cargo-features = ["edition2024"] cargo-features = ["edition2024"]
[workspace.dependencies] [workspace.dependencies]
@ -2519,7 +2527,8 @@ a = {path = "a", default-features = false}
# After build_dependencies line # After build_dependencies line
a = {path = "a", default-features = false} a = {path = "a", default-features = false}
# After build_dependencies table # After build_dependencies table
"#,
"#]],
); );
} }
@ -2564,9 +2573,10 @@ target-dep = { version = "0.1.0", optional = true }
", ",
) )
.run(); .run();
assert_eq!( assert_e2e().eq(
p.read_file("Cargo.toml"), p.read_file("Cargo.toml"),
r#" str![[r#"
[package] [package]
name = "foo" name = "foo"
version = "0.1.0" version = "0.1.0"
@ -2585,7 +2595,8 @@ target-dep = { version = "0.1.0", optional = true }
bar = ["dep:bar"] bar = ["dep:bar"]
baz = ["dep:baz"] baz = ["dep:baz"]
target-dep = ["dep:target-dep"] target-dep = ["dep:target-dep"]
"#
"#]],
); );
} }
@ -2633,9 +2644,10 @@ target-dep = ["dep:target-dep"]
", ",
) )
.run(); .run();
assert_eq!( assert_e2e().eq(
p.read_file("Cargo.toml"), p.read_file("Cargo.toml"),
r#" str![[r#"
[package] [package]
name = "foo" name = "foo"
version = "0.1.0" version = "0.1.0"
@ -2654,7 +2666,8 @@ target-dep = { version = "0.1.0", optional = true }
target-dep = ["dep:target-dep"] target-dep = ["dep:target-dep"]
bar = ["dep:bar"] bar = ["dep:bar"]
baz = ["dep:baz"] baz = ["dep:baz"]
"#
"#]],
); );
} }
@ -2777,11 +2790,12 @@ dep_df_false = { version = "0.1.0", default-features = false }
) )
.run(); .run();
assert_eq!(p.read_file("pkg_default/Cargo.toml"), pkg_default); assert_e2e().eq(p.read_file("pkg_default/Cargo.toml"), pkg_default);
assert_eq!(p.read_file("pkg_df_true/Cargo.toml"), pkg_df_true); assert_e2e().eq(p.read_file("pkg_df_true/Cargo.toml"), pkg_df_true);
assert_eq!( assert_e2e().eq(
p.read_file("pkg_df_false/Cargo.toml"), p.read_file("pkg_df_false/Cargo.toml"),
r#" str![[r#"
[package] [package]
name = "pkg_df_false" name = "pkg_df_false"
version = "0.1.0" version = "0.1.0"
@ -2801,6 +2815,7 @@ dep_df_false = { workspace = true, default-features = false }
dep_simple = { workspace = true} dep_simple = { workspace = true}
dep_df_true = { workspace = true} dep_df_true = { workspace = true}
dep_df_false = { workspace = true, default-features = false } dep_df_false = { workspace = true, default-features = false }
"#
"#]],
); );
} }