summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2020-02-17 18:08:47 -0500
committerAndrew Gallant <jamslam@gmail.com>2020-02-17 19:24:53 -0500
commit0bc4f0447b05468f043e06278a3ca2b1c5646f9b (patch)
tree8a7e03399262af04a47ad1397fca74f654bfea5b /tests
parentc95f29e3ba46ef622481995ab01fd9f4e931345c (diff)
style: rustfmt everything
This is why I was so intent on clearing the PR queue. This will effectively invalidate all existing patches, so I wanted to start from a clean slate. We do make one little tweak: we put the default type definitions in their own file and tell rustfmt to keep its grubby mits off of it. We also sort it lexicographically and hopefully will enforce that from here on.
Diffstat (limited to 'tests')
-rw-r--r--tests/binary.rs111
-rw-r--r--tests/feature.rs140
-rw-r--r--tests/json.rs70
-rw-r--r--tests/macros.rs2
-rw-r--r--tests/misc.rs41
-rw-r--r--tests/multiline.rs36
-rw-r--r--tests/regression.rs102
-rw-r--r--tests/util.rs67
8 files changed, 262 insertions, 307 deletions
diff --git a/tests/binary.rs b/tests/binary.rs
index d2640988..b16dcf9d 100644
--- a/tests/binary.rs
+++ b/tests/binary.rs
@@ -36,9 +36,7 @@ const HAY: &'static [u8] = include_bytes!("./data/sherlock-nul.txt");
// that matches our file.
rgtest!(after_match1_implicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "Project Gutenberg EBook", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "Project Gutenberg EBook", "-g", "hay"]);
let expected = "\
hay:1:The Project Gutenberg EBook of A Study In Scarlet, by Arthur Conan Doyle
@@ -51,9 +49,7 @@ WARNING: stopped searching binary file hay after match (found \"\\u{0}\" byte ar
// explicitly. This results in identical behavior, but a different message.
rgtest!(after_match1_explicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "Project Gutenberg EBook", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "Project Gutenberg EBook", "hay"]);
let expected = "\
1:The Project Gutenberg EBook of A Study In Scarlet, by Arthur Conan Doyle
@@ -64,9 +60,7 @@ Binary file matches (found \"\\u{0}\" byte around offset 9741)
// Like after_match1_explicit, except we feed our content on stdin.
rgtest!(after_match1_stdin, |_: Dir, mut cmd: TestCommand| {
- cmd.args(&[
- "--no-mmap", "-n", "Project Gutenberg EBook",
- ]);
+ cmd.args(&["--no-mmap", "-n", "Project Gutenberg EBook"]);
let expected = "\
1:The Project Gutenberg EBook of A Study In Scarlet, by Arthur Conan Doyle
@@ -81,7 +75,12 @@ Binary file matches (found \"\\u{0}\" byte around offset 9741)
rgtest!(after_match1_implicit_binary, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
cmd.args(&[
- "--no-mmap", "-n", "--binary", "Project Gutenberg EBook", "-g", "hay",
+ "--no-mmap",
+ "-n",
+ "--binary",
+ "Project Gutenberg EBook",
+ "-g",
+ "hay",
]);
let expected = "\
@@ -96,7 +95,12 @@ Binary file hay matches (found \"\\u{0}\" byte around offset 9741)
rgtest!(after_match1_implicit_text, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
cmd.args(&[
- "--no-mmap", "-n", "--text", "Project Gutenberg EBook", "-g", "hay",
+ "--no-mmap",
+ "-n",
+ "--text",
+ "Project Gutenberg EBook",
+ "-g",
+ "hay",
]);
let expected = "\
@@ -109,9 +113,7 @@ hay:1:The Project Gutenberg EBook of A Study In Scarlet, by Arthur Conan Doyle
// detection should be performed.
rgtest!(after_match1_explicit_text, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "--text", "Project Gutenberg EBook", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "--text", "Project Gutenberg EBook", "hay"]);
let expected = "\
1:The Project Gutenberg EBook of A Study In Scarlet, by Arthur Conan Doyle
@@ -134,9 +136,7 @@ rgtest!(after_match1_explicit_text, |dir: Dir, mut cmd: TestCommand| {
// --quiet flag is set. See the next test.)
rgtest!(after_match1_implicit_path, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-l", "Project Gutenberg EBook", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-l", "Project Gutenberg EBook", "-g", "hay"]);
eqnice!("hay\n", cmd.stdout());
});
@@ -145,9 +145,7 @@ rgtest!(after_match1_implicit_path, |dir: Dir, mut cmd: TestCommand| {
// manifest as an exit code with no output.)
rgtest!(after_match1_implicit_quiet, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-q", "Project Gutenberg EBook", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-q", "Project Gutenberg EBook", "-g", "hay"]);
eqnice!("", cmd.stdout());
});
@@ -157,32 +155,34 @@ rgtest!(after_match1_implicit_quiet, |dir: Dir, mut cmd: TestCommand| {
// detects the binary data and suppresses output.
rgtest!(after_match1_implicit_count, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-c", "Project Gutenberg EBook", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-c", "Project Gutenberg EBook", "-g", "hay"]);
cmd.assert_err();
});
// Like after_match1_implicit_count, except the --binary flag is provided,
// which makes ripgrep disable binary data filtering even for implicit files.
-rgtest!(after_match1_implicit_count_binary, |dir: Dir, mut cmd: TestCommand| {
- dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-c", "--binary",
- "Project Gutenberg EBook",
- "-g", "hay",
- ]);
- eqnice!("hay:1\n", cmd.stdout());
-});
+rgtest!(
+ after_match1_implicit_count_binary,
+ |dir: Dir, mut cmd: TestCommand| {
+ dir.create_bytes("hay", HAY);
+ cmd.args(&[
+ "--no-mmap",
+ "-c",
+ "--binary",
+ "Project Gutenberg EBook",
+ "-g",
+ "hay",
+ ]);
+ eqnice!("hay:1\n", cmd.stdout());
+ }
+);
// Like after_match1_implicit_count, except the file path is provided
// explicitly, so binary filtering is disabled and a count is correctly
// reported.
rgtest!(after_match1_explicit_count, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-c", "Project Gutenberg EBook", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-c", "Project Gutenberg EBook", "hay"]);
eqnice!("1\n", cmd.stdout());
});
@@ -191,9 +191,11 @@ rgtest!(after_match1_explicit_count, |dir: Dir, mut cmd: TestCommand| {
rgtest!(after_match2_implicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
cmd.args(&[
- "--no-mmap", "-n",
+ "--no-mmap",
+ "-n",
"Project Gutenberg EBook|a medical student",
- "-g", "hay",
+ "-g",
+ "hay",
]);
let expected = "\
@@ -208,9 +210,12 @@ WARNING: stopped searching binary file hay after match (found \"\\u{0}\" byte ar
rgtest!(after_match2_implicit_text, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
cmd.args(&[
- "--no-mmap", "-n", "--text",
+ "--no-mmap",
+ "-n",
+ "--text",
"Project Gutenberg EBook|a medical student",
- "-g", "hay",
+ "-g",
+ "hay",
]);
let expected = "\
@@ -224,9 +229,7 @@ hay:236:\"And yet you say he is not a medical student?\"
// after a NUL byte.
rgtest!(before_match1_implicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "Heaven", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "Heaven", "-g", "hay"]);
cmd.assert_err();
});
@@ -234,9 +237,7 @@ rgtest!(before_match1_implicit, |dir: Dir, mut cmd: TestCommand| {
// occurs after a NUL byte when a file is explicitly searched.
rgtest!(before_match1_explicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "Heaven", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "Heaven", "hay"]);
let expected = "\
Binary file matches (found \"\\u{0}\" byte around offset 9741)
@@ -249,9 +250,7 @@ Binary file matches (found \"\\u{0}\" byte around offset 9741)
// the file were given explicitly.
rgtest!(before_match1_implicit_binary, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "--binary", "Heaven", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "--binary", "Heaven", "-g", "hay"]);
let expected = "\
Binary file hay matches (found \"\\u{0}\" byte around offset 9741)
@@ -263,9 +262,7 @@ Binary file hay matches (found \"\\u{0}\" byte around offset 9741)
// detection should be performed.
rgtest!(before_match1_implicit_text, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "--text", "Heaven", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "--text", "Heaven", "-g", "hay"]);
let expected = "\
hay:238:\"No. Heaven knows what the objects of his studies are. But here we
@@ -277,9 +274,7 @@ hay:238:\"No. Heaven knows what the objects of his studies are. But here we
// before a NUL byte, but within the same buffer as the NUL byte.
rgtest!(before_match2_implicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "a medical student", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "a medical student", "-g", "hay"]);
cmd.assert_err();
});
@@ -290,9 +285,7 @@ rgtest!(before_match2_implicit, |dir: Dir, mut cmd: TestCommand| {
// the behavior of GNU grep.)
rgtest!(before_match2_explicit, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "a medical student", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "a medical student", "hay"]);
let expected = "\
Binary file matches (found \"\\u{0}\" byte around offset 9741)
@@ -304,9 +297,7 @@ Binary file matches (found \"\\u{0}\" byte around offset 9741)
// detection should be performed.
rgtest!(before_match2_implicit_text, |dir: Dir, mut cmd: TestCommand| {
dir.create_bytes("hay", HAY);
- cmd.args(&[
- "--no-mmap", "-n", "--text", "a medical student", "-g", "hay",
- ]);
+ cmd.args(&["--no-mmap", "-n", "--text", "a medical student", "-g", "hay"]);
let expected = "\
hay:236:\"And yet you say he is not a medical student?\"
diff --git a/tests/feature.rs b/tests/feature.rs
index f3cf8463..0ae21c1a 100644
--- a/tests/feature.rs
+++ b/tests/feature.rs
@@ -1,5 +1,5 @@
use crate::hay::{SHERLOCK, SHERLOCK_CRLF};
-use crate::util::{Dir, TestCommand, sort_lines};
+use crate::util::{sort_lines, Dir, TestCommand};
// See: https://github.com/BurntSushi/ripgrep/issues/1
rgtest!(f1_sjis, |dir: Dir, mut cmd: TestCommand| {
@@ -181,8 +181,10 @@ rgtest!(f45_precedence_internal, |dir: Dir, mut cmd: TestCommand| {
dir.create("wat.log", "test");
cmd.args(&[
- "--ignore-file", ".not-an-ignore1",
- "--ignore-file", ".not-an-ignore2",
+ "--ignore-file",
+ ".not-an-ignore1",
+ "--ignore-file",
+ ".not-an-ignore2",
"test",
]);
eqnice!("imp.log:test\n", cmd.stdout());
@@ -388,28 +390,34 @@ rgtest!(f362_exceeds_regex_size_limit, |dir: Dir, mut cmd: TestCommand| {
// See: https://github.com/BurntSushi/ripgrep/issues/362
#[cfg(target_pointer_width = "32")]
-rgtest!(f362_u64_to_narrow_usize_overflow, |dir: Dir, mut cmd: TestCommand| {
- // --dfa-size-limit doesn't apply to PCRE2.
- if dir.is_pcre2() {
- return;
+rgtest!(
+ f362_u64_to_narrow_usize_overflow,
+ |dir: Dir, mut cmd: TestCommand| {
+ // --dfa-size-limit doesn't apply to PCRE2.
+ if dir.is_pcre2() {
+ return;
+ }
+ dir.create_size("foo", 1000000);
+
+ // 2^35 * 2^20 is ok for u64, but not for usize
+ cmd.arg("--dfa-size-limit").arg("34359738368M").arg("--files");
+ cmd.assert_err();
}
- dir.create_size("foo", 1000000);
-
- // 2^35 * 2^20 is ok for u64, but not for usize
- cmd.arg("--dfa-size-limit").arg("34359738368M").arg("--files");
- cmd.assert_err();
-});
+);
// See: https://github.com/BurntSushi/ripgrep/issues/411
-rgtest!(f411_single_threaded_search_stats, |dir: Dir, mut cmd: TestCommand| {
- dir.create("sherlock", SHERLOCK);
-
- let lines = cmd.arg("--stats").arg("Sherlock").stdout();
- assert!(lines.contains("2 matched lines"));
- assert!(lines.contains("1 files contained matches"));
- assert!(lines.contains("1 files searched"));
- assert!(lines.contains("seconds"));
-});
+rgtest!(
+ f411_single_threaded_search_stats,
+ |dir: Dir, mut cmd: TestCommand| {
+ dir.create("sherlock", SHERLOCK);
+
+ let lines = cmd.arg("--stats").arg("Sherlock").stdout();
+ assert!(lines.contains("2 matched lines"));
+ assert!(lines.contains("1 files contained matches"));
+ assert!(lines.contains("1 files searched"));
+ assert!(lines.contains("seconds"));
+ }
+);
rgtest!(f411_parallel_search_stats, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock_1", SHERLOCK);
@@ -568,7 +576,7 @@ rgtest!(f948_exit_code_error, |dir: Dir, mut cmd: TestCommand| {
// See: https://github.com/BurntSushi/ripgrep/issues/917
rgtest!(f917_trim, |dir: Dir, mut cmd: TestCommand| {
-const SHERLOCK: &'static str = "\
+ const SHERLOCK: &'static str = "\
zzz
For the Doctor Watsons of this world, as opposed to the Sherlock
Holmeses, success in the province of detective work must always
@@ -578,9 +586,7 @@ but Doctor Watson has to have it taken out for him and dusted,
and exhibited clearly, with a label attached.
";
dir.create("sherlock", SHERLOCK);
- cmd.args(&[
- "-n", "-B1", "-A2", "--trim", "Holmeses", "sherlock",
- ]);
+ cmd.args(&["-n", "-B1", "-A2", "--trim", "Holmeses", "sherlock"]);
let expected = "\
2-For the Doctor Watsons of this world, as opposed to the Sherlock
@@ -596,7 +602,7 @@ but Doctor Watson has to have it taken out for him and dusted,
// This is like f917_trim, except this tests that trimming occurs even when the
// whitespace is part of a match.
rgtest!(f917_trim_match, |dir: Dir, mut cmd: TestCommand| {
-const SHERLOCK: &'static str = "\
+ const SHERLOCK: &'static str = "\
zzz
For the Doctor Watsons of this world, as opposed to the Sherlock
Holmeses, success in the province of detective work must always
@@ -606,9 +612,7 @@ but Doctor Watson has to have it taken out for him and dusted,
and exhibited clearly, with a label attached.
";
dir.create("sherlock", SHERLOCK);
- cmd.args(&[
- "-n", "-B1", "-A2", "--trim", r"\s+Holmeses", "sherlock",
- ]);
+ cmd.args(&["-n", "-B1", "-A2", "--trim", r"\s+Holmeses", "sherlock"]);
let expected = "\
2-For the Doctor Watsons of this world, as opposed to the Sherlock
@@ -636,7 +640,8 @@ rgtest!(f993_null_data, |dir: Dir, mut cmd: TestCommand| {
rgtest!(f1078_max_columns_preview1, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-M46", "--max-columns-preview",
+ "-M46",
+ "--max-columns-preview",
"exhibited|dusted|has to have it",
]);
@@ -650,7 +655,8 @@ sherlock:and exhibited clearly, with a label attached.
rgtest!(f1078_max_columns_preview2, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-M43", "--max-columns-preview",
+ "-M43",
+ "--max-columns-preview",
// Doing a replacement forces ripgrep to show the number of remaining
// matches. Normally, this happens by default when printing a tty with
// colors.
@@ -702,10 +708,7 @@ sherlock:For the Doctor Watsons of this world, as opposed to the Sherlock
// Tests if without encoding 'none' flag null bytes are consumed by automatic
// encoding detection.
rgtest!(f1207_auto_encoding, |dir: Dir, mut cmd: TestCommand| {
- dir.create_bytes(
- "foo",
- b"\xFF\xFE\x00\x62"
- );
+ dir.create_bytes("foo", b"\xFF\xFE\x00\x62");
cmd.arg("-a").arg("\\x00").arg("foo");
cmd.assert_exit_code(1);
});
@@ -720,10 +723,7 @@ rgtest!(f1207_ignore_encoding, |dir: Dir, mut cmd: TestCommand| {
return;
}
- dir.create_bytes(
- "foo",
- b"\xFF\xFE\x00\x62"
- );
+ dir.create_bytes("foo", b"\xFF\xFE\x00\x62");
cmd.arg("--encoding").arg("none").arg("-a").arg("\\x00").arg("foo");
eqnice!("\u{FFFD}\u{FFFD}\x00b\n", cmd.stdout());
});
@@ -734,25 +734,22 @@ rgtest!(f1414_no_require_git, |dir: Dir, mut cmd: TestCommand| {
dir.create("foo", "");
dir.create("bar", "");
- let stdout = cmd.args(&[
- "--sort", "path",
- "--files",
- ]).stdout();
+ let stdout = cmd.args(&["--sort", "path", "--files"]).stdout();
eqnice!("bar\nfoo\n", stdout);
- let stdout = cmd.args(&[
- "--sort", "path",
- "--files",
- "--no-require-git",
- ]).stdout();
+ let stdout =
+ cmd.args(&["--sort", "path", "--files", "--no-require-git"]).stdout();
eqnice!("bar\n", stdout);
- let stdout = cmd.args(&[
- "--sort", "path",
- "--files",
- "--no-require-git",
- "--require-git",
- ]).stdout();
+ let stdout = cmd
+ .args(&[
+ "--sort",
+ "path",
+ "--files",
+ "--no-require-git",
+ "--require-git",
+ ])
+ .stdout();
eqnice!("bar\nfoo\n", stdout);
});
@@ -770,12 +767,7 @@ rgtest!(f1420_no_ignore_dot, |dir: Dir, mut cmd: TestCommand| {
rgtest!(no_context_sep, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx");
- cmd.args(&[
- "-A1",
- "--no-context-separator",
- "foo",
- "test",
- ]);
+ cmd.args(&["-A1", "--no-context-separator", "foo", "test"]);
eqnice!("foo\nctx\nfoo\nctx\n", cmd.stdout());
});
@@ -783,7 +775,8 @@ rgtest!(no_context_sep_overrides, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx");
cmd.args(&[
"-A1",
- "--context-separator", "AAA",
+ "--context-separator",
+ "AAA",
"--no-context-separator",
"foo",
"test",
@@ -796,7 +789,8 @@ rgtest!(no_context_sep_overridden, |dir: Dir, mut cmd: TestCommand| {
cmd.args(&[
"-A1",
"--no-context-separator",
- "--context-separator", "AAA",
+ "--context-separator",
+ "AAA",
"foo",
"test",
]);
@@ -805,33 +799,19 @@ rgtest!(no_context_sep_overridden, |dir: Dir, mut cmd: TestCommand| {
rgtest!(context_sep, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx");
- cmd.args(&[
- "-A1",
- "--context-separator", "AAA",
- "foo",
- "test",
- ]);
+ cmd.args(&["-A1", "--context-separator", "AAA", "foo", "test"]);
eqnice!("foo\nctx\nAAA\nfoo\nctx\n", cmd.stdout());
});
rgtest!(context_sep_default, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx");
- cmd.args(&[
- "-A1",
- "foo",
- "test",
- ]);
+ cmd.args(&["-A1", "foo", "test"]);
eqnice!("foo\nctx\n--\nfoo\nctx\n", cmd.stdout());
});
rgtest!(context_sep_empty, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx");
- cmd.args(&[
- "-A1",
- "--context-separator", "",
- "foo",
- "test",
- ]);
+ cmd.args(&["-A1", "--context-separator", "", "foo", "test"]);
eqnice!("foo\nctx\n\nfoo\nctx\n", cmd.stdout());
});
diff --git a/tests/json.rs b/tests/json.rs
index f49c9061..477b36df 100644
--- a/tests/json.rs
+++ b/tests/json.rs
@@ -108,8 +108,12 @@ enum Data {
}
impl Data {
- fn text(s: &str) -> Data { Data::Text { text: s.to_string() } }
- fn bytes(s: &str) -> Data { Data::Bytes { bytes: s.to_string() } }
+ fn text(s: &str) -> Data {
+ Data::Text { text: s.to_string() }
+ }
+ fn bytes(s: &str) -> Data {
+ Data::Bytes { bytes: s.to_string() }
+ }
}
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
@@ -172,31 +176,17 @@ rgtest!(basic, |dir: Dir, mut cmd: TestCommand| {
),
line_number: Some(3),
absolute_offset: 129,
- submatches: vec![
- SubMatch {
- m: Data::text("Sherlock Holmes"),
- start: 48,
- end: 63,
- },
- ],
+ submatches: vec![SubMatch {
+ m: Data::text("Sherlock Holmes"),
+ start: 48,
+ end: 63,
+ },],
}
);
- assert_eq!(
- msgs[3].unwrap_end().path,
- Some(Data::text("sherlock"))
- );
- assert_eq!(
- msgs[3].unwrap_end().binary_offset,
- None
- );
- assert_eq!(
- msgs[4].unwrap_summary().stats.searches_with_match,
- 1
- );
- assert_eq!(
- msgs[4].unwrap_summary().stats.bytes_printed,
- 494
- );
+ assert_eq!(msgs[3].unwrap_end().path, Some(Data::text("sherlock")));
+ assert_eq!(msgs[3].unwrap_end().binary_offset, None);
+ assert_eq!(msgs[4].unwrap_summary().stats.searches_with_match, 1);
+ assert_eq!(msgs[4].unwrap_summary().stats.bytes_printed, 494);
});
#[cfg(unix)]
@@ -239,13 +229,11 @@ rgtest!(notutf8, |dir: Dir, mut cmd: TestCommand| {
lines: Data::bytes("cXV1eP9iYXo="),
line_number: Some(1),
absolute_offset: 0,
- submatches: vec![
- SubMatch {
- m: Data::bytes("/w=="),
- start: 4,
- end: 5,
- },
- ],
+ submatches: vec![SubMatch {
+ m: Data::bytes("/w=="),
+ start: 4,
+ end: 5,
+ },],
}
);
});
@@ -282,13 +270,11 @@ rgtest!(notutf8_file, |dir: Dir, mut cmd: TestCommand| {
lines: Data::bytes("cXV1eP9iYXo="),
line_number: Some(1),
absolute_offset: 0,
- submatches: vec![
- SubMatch {
- m: Data::bytes("/w=="),
- start: 4,
- end: 5,
- },
- ],
+ submatches: vec![SubMatch {
+ m: Data::bytes("/w=="),
+ start: 4,
+ end: 5,
+ },],
}
);
});
@@ -306,11 +292,7 @@ rgtest!(crlf, |dir: Dir, mut cmd: TestCommand| {
assert_eq!(
msgs[1].unwrap_match().submatches[0].clone(),
- SubMatch {
- m: Data::text("Sherlock"),
- start: 56,
- end: 64,
- },
+ SubMatch { m: Data::text("Sherlock"), start: 56, end: 64 },
);
});
diff --git a/tests/macros.rs b/tests/macros.rs
index 28b799d9..7e5958c3 100644
--- a/tests/macros.rs
+++ b/tests/macros.rs
@@ -11,7 +11,7 @@ macro_rules! rgtest {
$fun(dir, cmd);
}
}
- }
+ };
}
#[macro_export]
diff --git a/tests/misc.rs b/tests/misc.rs
index b4026702..3f8c3ea9 100644
--- a/tests/misc.rs
+++ b/tests/misc.rs
@@ -1,5 +1,5 @@
use crate::hay::SHERLOCK;
-use crate::util::{Dir, TestCommand, cmd_exists, sort_lines};
+use crate::util::{cmd_exists, sort_lines, Dir, TestCommand};
// This file contains "miscellaneous" tests that were either written before
// features were tracked more explicitly, or were simply written without
@@ -65,8 +65,10 @@ rgtest!(with_heading, |dir: Dir, mut cmd: TestCommand| {
cmd.args(&[
// This forces the issue since --with-filename is disabled by default
// when searching one file.
- "--with-filename", "--heading",
- "Sherlock", "sherlock",
+ "--with-filename",
+ "--heading",
+ "Sherlock",
+ "sherlock",
]);
let expected = "\
@@ -184,9 +186,7 @@ be, to a very large extent, the result of luck. FooBar Holmes
rgtest!(replace_groups, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
- cmd.args(&[
- "-r", "$2, $1", "([A-Z][a-z]+) ([A-Z][a-z]+)", "sherlock",
- ]);
+ cmd.args(&["-r", "$2, $1", "([A-Z][a-z]+) ([A-Z][a-z]+)", "sherlock"]);
let expected = "\
For the Watsons, Doctor of this world, as opposed to the Sherlock
@@ -199,7 +199,8 @@ but Watson, Doctor has to have it taken out for him and dusted,
rgtest!(replace_named_groups, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-r", "$last, $first",
+ "-r",
+ "$last, $first",
"(?P<first>[A-Z][a-z]+) (?P<last>[A-Z][a-z]+)",
"sherlock",
]);
@@ -279,9 +280,7 @@ rgtest!(file_type_add, |dir: Dir, mut cmd: TestCommand| {
dir.create("file.py", "Sherlock");
dir.create("file.rs", "Sherlock");
dir.create("file.wat", "Sherlock");
- cmd.args(&[
- "--type-add", "wat:*.wat", "-t", "wat", "Sherlock",
- ]);
+ cmd.args(&["--type-add", "wat:*.wat", "-t", "wat", "Sherlock"]);
eqnice!("file.wat:Sherlock\n", cmd.stdout());
});
@@ -292,9 +291,12 @@ rgtest!(file_type_add_compose, |dir: Dir, mut cmd: TestCommand| {
dir.create("file.rs", "Sherlock");
dir.create("file.wat", "Sherlock");
cmd.args(&[
- "--type-add", "wat:*.wat",
- "--type-add", "combo:include:wat,py",
- "-t", "combo",
+ "--type-add",
+ "wat:*.wat",
+ "--type-add",
+ "combo:include:wat,py",
+ "-t",
+ "combo",
"Sherlock",
]);
@@ -394,11 +396,7 @@ rgtest!(count_matches_via_only, |dir: Dir, mut cmd: TestCommand| {
rgtest!(include_zero, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
- cmd.args(&[
- "--count",
- "--include-zero",
- "nada",
- ]);
+ cmd.args(&["--count", "--include-zero", "nada"]);
cmd.assert_err();
let output = cmd.cmd().output().unwrap();
@@ -410,12 +408,7 @@ rgtest!(include_zero, |dir: Dir, mut cmd: TestCommand| {
rgtest!(include_zero_override, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
- cmd.args(&[
- "--count",
- "--include-zero",
- "--no-include-zero",
- "nada",
- ]);
+ cmd.args(&["--count", "--include-zero", "--no-include-zero", "nada"]);
cmd.assert_err();
let output = cmd.cmd().output().unwrap();
diff --git a/tests/multiline.rs b/tests/multiline.rs
index 64065f72..67fa650d 100644
--- a/tests/multiline.rs
+++ b/tests/multiline.rs
@@ -20,9 +20,7 @@ rgtest!(overlap2, |dir: Dir, mut cmd: TestCommand| {
// Tests that even in a multiline search, a '.' does not match a newline.
rgtest!(dot_no_newline, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
- cmd.args(&[
- "-n", "-U", "of this world.+detective work", "sherlock",
- ]);
+ cmd.args(&["-n", "-U", "of this world.+detective work", "sherlock"]);
cmd.assert_err();
});
@@ -30,8 +28,11 @@ rgtest!(dot_no_newline, |dir: Dir, mut cmd: TestCommand| {
rgtest!(dot_all, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-n", "-U", "--multiline-dotall",
- "of this world.+detective work", "sherlock",
+ "-n",
+ "-U",
+ "--multiline-dotall",
+ "of this world.+detective work",
+ "sherlock",
]);
let expected = "\
@@ -45,8 +46,11 @@ rgtest!(dot_all, |dir: Dir, mut cmd: TestCommand| {
rgtest!(only_matching, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-n", "-U", "--only-matching",
- r"Watson|Sherlock\p{Any}+?Holmes", "sherlock",
+ "-n",
+ "-U",
+ "--only-matching",
+ r"Watson|Sherlock\p{Any}+?Holmes",
+ "sherlock",
]);
let expected = "\
@@ -63,8 +67,11 @@ rgtest!(only_matching, |dir: Dir, mut cmd: TestCommand| {
rgtest!(vimgrep, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-n", "-U", "--vimgrep",
- r"Watson|Sherlock\p{Any}+?Holmes", "sherlock",
+ "-n",
+ "-U",
+ "--vimgrep",
+ r"Watson|Sherlock\p{Any}+?Holmes",
+ "sherlock",
]);
let expected = "\
@@ -81,9 +88,7 @@ sherlock:5:12:but Doctor Watson has to have it taken out for him and dusted,
// important test because multiline search must read the entire contents of
// what it is searching into memory before executing the search.
rgtest!(stdin, |_: Dir, mut cmd: TestCommand| {
- cmd.args(&[
- "-n", "-U", r"of this world\p{Any}+?detective work",
- ]);
+ cmd.args(&["-n", "-U", r"of this world\p{Any}+?detective work"]);
let expected = "\
1:For the Doctor Watsons of this world, as opposed to the Sherlock
2:Holmeses, success in the province of detective work must always
@@ -95,8 +100,11 @@ rgtest!(stdin, |_: Dir, mut cmd: TestCommand| {
rgtest!(context, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", SHERLOCK);
cmd.args(&[
- "-n", "-U", "-C1",
- r"detective work\p{Any}+?result of luck", "sherlock",
+ "-n",
+ "-U",
+ "-C1",
+ r"detective work\p{Any}+?result of luck",
+ "sherlock",
]);
let expected = "\
diff --git a/tests/regression.rs b/tests/regression.rs
index 29f15a27..89297b9c 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -1,5 +1,5 @@
use crate::hay::SHERLOCK;
-use crate::util::{Dir, TestCommand, sort_lines};
+use crate::util::{sort_lines, Dir, TestCommand};
// See: https://github.com/BurntSushi/ripgrep/issues/16
rgtest!(r16, |dir: Dir, mut cmd: TestCommand| {
@@ -346,7 +346,10 @@ rgtest!(r391, |dir: Dir, mut cmd: TestCommand| {
dir.create(".git/description", "");
cmd.args(&[
- "--no-ignore", "--hidden", "--follow", "--files",
+ "--no-ignore",
+ "--hidden",
+ "--follow",
+ "--files",
"--glob",
"!{.git,node_modules,plugged}/**",
"--glob",
@@ -371,14 +374,18 @@ rgtest!(r405, |dir: Dir, mut cmd: TestCommand| {
rgtest!(r428_color_context_path, |dir: Dir, mut cmd: TestCommand| {
dir.create("sherlock", "foo\nbar");
cmd.args(&[
- "-A1", "-H", "--no-heading", "-N",
- "--colors=match:none", "--color=always",
+ "-A1",
+ "-H",
+ "--no-heading",
+ "-N",
+ "--colors=match:none",
+ "--color=always",
"foo",
]);
let expected = format!(
"{colored_path}:foo\n{colored_path}-bar\n",
- colored_path=
+ colored_path =
"\x1b\x5b\x30\x6d\x1b\x5b\x33\x35\x6dsherlock\x1b\x5b\x30\x6d"
);
eqnice!(expected, cmd.stdout());
@@ -414,9 +421,7 @@ rgtest!(r451_only_matching_as_in_issue, |dir: Dir, mut cmd: TestCommand| {
// See: https://github.com/BurntSushi/ripgrep/issues/451
rgtest!(r451_only_matching, |dir: Dir, mut cmd: TestCommand| {
dir.create("digits.txt", "1 2 3\n123\n");
- cmd.args(&[
- "--only-matching", "--column", r"[0-9]", "digits.txt",
- ]);
+ cmd.args(&["--only-matching", "--column", r"[0-9]", "digits.txt"]);
let expected = "\
1:1:1
@@ -517,11 +522,16 @@ rgtest!(r568_leading_hyphen_option_args, |dir: Dir, mut cmd: TestCommand| {
rgtest!(r599, |dir: Dir, mut cmd: TestCommand| {
dir.create("input.txt", "\n\ntest\n");
cmd.args(&[
- "--color", "ansi",
- "--colors", "path:none",
- "--colors", "line:none",
- "--colors", "match:fg:red",
- "--colors", "match:style:nobold",
+ "--color",
+ "ansi",
+ "--colors",
+ "path:none",
+ "--colors",
+ "line:none",
+ "--colors",
+ "match:fg:red",
+ "--colors",
+ "match:style:nobold",
"--line-number",
r"^$",
"input.txt",
@@ -707,16 +717,19 @@ rgtest!(r1203_reverse_suffix_literal, |dir: Dir, _: TestCommand| {
});
// See: https://github.com/BurntSushi/ripgrep/issues/1223
-rgtest!(r1223_no_dir_check_for_default_path, |dir: Dir, mut cmd: TestCommand| {
- dir.create_dir("-");
- dir.create("a.json", "{}");
- dir.create("a.txt", "some text");
-
- eqnice!(
- "a.json\na.txt\n",
- sort_lines(&cmd.arg("a").pipe(b"a.json\na.txt"))
- );
-});
+rgtest!(
+ r1223_no_dir_check_for_default_path,
+ |dir: Dir, mut cmd: TestCommand| {
+ dir.create_dir("-");
+ dir.create("a.json", "{}");
+ dir.create("a.txt", "some text");
+
+ eqnice!(
+ "a.json\na.txt\n",
+ sort_lines(&cmd.arg("a").pipe(b"a.json\na.txt"))
+ );
+ }
+);
// See: https://github.com/BurntSushi/ripgrep/issues/1259
rgtest!(r1259_drop_last_byte_nonl, |dir: Dir, mut cmd: TestCommand| {
@@ -734,7 +747,8 @@ rgtest!(r1319, |dir: Dir, mut cmd: TestCommand| {
dir.create("input", "CCAGCTACTCGGGAGGCT