feature.rs (ripgrep-12.1.1) | : | feature.rs (ripgrep-13.0.0) | ||
---|---|---|---|---|
skipping to change at line 790 | skipping to change at line 790 | |||
eqnice!("foo\n", cmd.arg("--ignore-files").stdout()); | eqnice!("foo\n", cmd.arg("--ignore-files").stdout()); | |||
// Test that the -u flag does not disable --ignore-file. | // Test that the -u flag does not disable --ignore-file. | |||
let mut cmd = dir.command(); | let mut cmd = dir.command(); | |||
cmd.arg("--sort").arg("path").arg("--files"); | cmd.arg("--sort").arg("path").arg("--files"); | |||
cmd.arg("--ignore-file").arg(".myignore"); | cmd.arg("--ignore-file").arg(".myignore"); | |||
eqnice!("foo\n", cmd.stdout()); | eqnice!("foo\n", cmd.stdout()); | |||
eqnice!("foo\n", cmd.arg("-u").stdout()); | eqnice!("foo\n", cmd.arg("-u").stdout()); | |||
}); | }); | |||
// See: https://github.com/BurntSushi/ripgrep/issues/1404 | ||||
rgtest!(f1404_nothing_searched_warning, |dir: Dir, mut cmd: TestCommand| { | ||||
dir.create(".ignore", "ignored-dir/**"); | ||||
dir.create_dir("ignored-dir"); | ||||
dir.create("ignored-dir/foo", "needle"); | ||||
// Test that, if ripgrep searches only ignored folders/files, then there | ||||
// is a non-zero exit code. | ||||
cmd.arg("needle"); | ||||
cmd.assert_err(); | ||||
// Test that we actually get an error message that we expect. | ||||
let output = cmd.cmd().output().unwrap(); | ||||
let stderr = String::from_utf8_lossy(&output.stderr); | ||||
let expected = "\ | ||||
No files were searched, which means ripgrep probably applied \ | ||||
a filter you didn't expect.\n\ | ||||
Running with --debug will show why files are being skipped.\n\ | ||||
"; | ||||
eqnice!(expected, stderr); | ||||
}); | ||||
// See: https://github.com/BurntSushi/ripgrep/issues/1404 | ||||
rgtest!(f1404_nothing_searched_ignored, |dir: Dir, mut cmd: TestCommand| { | ||||
dir.create(".ignore", "ignored-dir/**"); | ||||
dir.create_dir("ignored-dir"); | ||||
dir.create("ignored-dir/foo", "needle"); | ||||
// Test that, if ripgrep searches only ignored folders/files, then there | ||||
// is a non-zero exit code. | ||||
cmd.arg("--no-messages").arg("needle"); | ||||
cmd.assert_err(); | ||||
// But since --no-messages is given, there should not be any error message | ||||
// printed. | ||||
let output = cmd.cmd().output().unwrap(); | ||||
let stderr = String::from_utf8_lossy(&output.stderr); | ||||
let expected = ""; | ||||
eqnice!(expected, stderr); | ||||
}); | ||||
// See: https://github.com/BurntSushi/ripgrep/issues/1842 | ||||
rgtest!(f1842_field_context_separator, |dir: Dir, _: TestCommand| { | ||||
dir.create("sherlock", SHERLOCK); | ||||
// Test the default. | ||||
let base = &["-n", "-A1", "Doctor Watsons", "sherlock"]; | ||||
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 | ||||
"; | ||||
eqnice!(expected, dir.command().args(base).stdout()); | ||||
// Test that it can be overridden. | ||||
let mut args = vec!["--field-context-separator", "!"]; | ||||
args.extend(base); | ||||
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 | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
// Test that it can use multiple bytes. | ||||
let mut args = vec!["--field-context-separator", "!!"]; | ||||
args.extend(base); | ||||
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 | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
// Test that unescaping works. | ||||
let mut args = vec!["--field-context-separator", r"\x7F"]; | ||||
args.extend(base); | ||||
let expected = "\ | ||||
1:For the Doctor Watsons of this world, as opposed to the Sherlock | ||||
2\x7FHolmeses, success in the province of detective work must always | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
// Test that an empty separator is OK. | ||||
let mut args = vec!["--field-context-separator", r""]; | ||||
args.extend(base); | ||||
let expected = "\ | ||||
1:For the Doctor Watsons of this world, as opposed to the Sherlock | ||||
2Holmeses, success in the province of detective work must always | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
}); | ||||
// See: https://github.com/BurntSushi/ripgrep/issues/1842 | ||||
rgtest!(f1842_field_match_separator, |dir: Dir, _: TestCommand| { | ||||
dir.create("sherlock", SHERLOCK); | ||||
// Test the default. | ||||
let base = &["-n", "Doctor Watsons", "sherlock"]; | ||||
let expected = "\ | ||||
1:For the Doctor Watsons of this world, as opposed to the Sherlock | ||||
"; | ||||
eqnice!(expected, dir.command().args(base).stdout()); | ||||
// Test that it can be overridden. | ||||
let mut args = vec!["--field-match-separator", "!"]; | ||||
args.extend(base); | ||||
let expected = "\ | ||||
1!For the Doctor Watsons of this world, as opposed to the Sherlock | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
// Test that it can use multiple bytes. | ||||
let mut args = vec!["--field-match-separator", "!!"]; | ||||
args.extend(base); | ||||
let expected = "\ | ||||
1!!For the Doctor Watsons of this world, as opposed to the Sherlock | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
// Test that unescaping works. | ||||
let mut args = vec!["--field-match-separator", r"\x7F"]; | ||||
args.extend(base); | ||||
let expected = "\ | ||||
1\x7FFor the Doctor Watsons of this world, as opposed to the Sherlock | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
// Test that an empty separator is OK. | ||||
let mut args = vec!["--field-match-separator", r""]; | ||||
args.extend(base); | ||||
let expected = "\ | ||||
1For the Doctor Watsons of this world, as opposed to the Sherlock | ||||
"; | ||||
eqnice!(expected, dir.command().args(&args).stdout()); | ||||
}); | ||||
rgtest!(no_context_sep, |dir: Dir, mut cmd: TestCommand| { | rgtest!(no_context_sep, |dir: Dir, mut cmd: TestCommand| { | |||
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); | 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()); | eqnice!("foo\nctx\nfoo\nctx\n", cmd.stdout()); | |||
}); | }); | |||
rgtest!(no_context_sep_overrides, |dir: Dir, mut cmd: TestCommand| { | rgtest!(no_context_sep_overrides, |dir: Dir, mut cmd: TestCommand| { | |||
dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); | dir.create("test", "foo\nctx\nbar\nctx\nfoo\nctx"); | |||
cmd.args(&[ | cmd.args(&[ | |||
"-A1", | "-A1", | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 134 lines changed or added |