From 98c04294341e17478729820edeb1b985a60ad658 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 30 Nov 2023 11:01:42 -0800 Subject: [PATCH] Add test for D51635478 and bump version Summary: Diff came from open-source without a test so here's a test. Reviewed By: evanworley, zertosh Differential Revision: D51682707 fbshipit-source-id: 137dd7e5fd36a7dfb50c6dd14857e8fd9bff5658 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a57b33..68c0a95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "fastmod" -version = "0.4.3" +version = "0.4.4" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 321619c..10b6a94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fastmod" -version = "0.4.3" +version = "0.4.4" authors = ["Scott Wolchok "] description = "Fast, partial replacement for codemod (find/replace tool for programmers)" edition = "2018" diff --git a/src/main.rs b/src/main.rs index f4ffce0..697c832 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1173,4 +1173,25 @@ mod tests { .assert() .success(); } + + #[test] + fn test_dollar_sign_in_replacement_string_with_fixed_strings() { + let contents = "something"; + let dir = create_test_files(&[("foo.txt", contents)]); + Command::cargo_bin("fastmod") + .unwrap() + .args(&[ + "-F", + "something", + "$foo.bar", + "--dir", + dir.path().to_str().unwrap(), + ]) + .write_stdin("y\n") + .assert() + .success(); + let file_path = dir.path().join("foo.txt"); + let new_contents = read_to_string(file_path).unwrap(); + assert_eq!(new_contents, "$foo.bar"); + } }