Enable --strip-cwd-prefix by default except with -0
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Fixes #1046.
authored by Tavian Barnes · committed by David Peter · parent e46d402 · Browse files · 3 files·+331 added−343 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+331 added−343 removed
- tests:+327 added−339 removed
- other:+4 added−4 removed
Provenance
- Commit
4419401- Tree
ad153c4- Author
Tavian Barnes <tavianator@tavianator.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
e46d402
3 files changed+331 added−343 removed
modified:src/app.rs+3 added-3 removed
717 unmodified lines718 Arg::new("strip-cwd-prefix")719 .long("strip-cwd-prefix")720 .conflicts_with_all(&["path", "search-path"])721 .hide_short_help(true)722- .help("strip './' prefix from non-tty outputs")722+ .help("strip './' prefix from -0/--print0 output")723 .long_help(724- "By default, relative paths are prefixed with './' when the output goes to a non \725- interactive terminal (TTY). Use this flag to disable this behaviour."724+ "By default, relative paths are prefixed with './' when -0/--print0 is given, to \725+ make them safer for use with xargs. Use this flag to disable this behaviour."726 )727 );728 729 if cfg!(unix) {45 unmodified linesmodified:src/main.rs+1 added-1 removed
383 unmodified lines384 }385 }),386 strip_cwd_prefix: (!matches.is_present("path")387 && !matches.is_present("search-path")388- && (interactive_terminal || matches.is_present("strip-cwd-prefix"))),388+ && (!matches.is_present("null_separator") || matches.is_present("strip-cwd-prefix"))),389 })390 }391 392 fn extract_command(175 unmodified linesmodified:tests/tests.rs+327 added-339 removed
59 unmodified lines60 #[test]61 fn test_simple() {62 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);63 64- te.assert_output(&["a.foo"], "./a.foo");65- te.assert_output(&["b.foo"], "./one/b.foo");66- te.assert_output(&["d.foo"], "./one/two/three/d.foo");64+ te.assert_output(&["a.foo"], "a.foo");65+ te.assert_output(&["b.foo"], "one/b.foo");66+ te.assert_output(&["d.foo"], "one/two/three/d.foo");67 68 te.assert_output(69 &["foo"],70- "./a.foo71- ./one/b.foo72- ./one/two/c.foo73- ./one/two/C.Foo274- ./one/two/three/d.foo75- ./one/two/three/directory_foo/",70+ "a.foo71+ one/b.foo72+ one/two/c.foo73+ one/two/C.Foo274+ one/two/three/d.foo75+ one/two/three/directory_foo/",76 );77 }78 79 /// Test each pattern type with an empty pattern.80 #[test]81 fn test_empty_pattern() {82 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);83- let expected = "./a.foo84- ./e1 e285- ./one/86- ./one/b.foo87- ./one/two/88- ./one/two/c.foo89- ./one/two/C.Foo290- ./one/two/three/91- ./one/two/three/d.foo92- ./one/two/three/directory_foo/93- ./symlink";83+ let expected = "a.foo84+ e1 e285+ one/86+ one/b.foo87+ one/two/88+ one/two/c.foo89+ one/two/C.Foo290+ one/two/three/91+ one/two/three/d.foo92+ one/two/three/directory_foo/93+ symlink";94 95 te.assert_output(&["--regex"], expected);96 te.assert_output(&["--fixed-strings"], expected);97 te.assert_output(&["--glob"], expected);110 unmodified lines208 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);209 210 te.assert_output(211 &["[a-c].foo"],212- "./a.foo213- ./one/b.foo214- ./one/two/c.foo215- ./one/two/C.Foo2",212+ "a.foo213+ one/b.foo214+ one/two/c.foo215+ one/two/C.Foo2",216 );217 218 te.assert_output(219 &["--case-sensitive", "[a-c].foo"],220- "./a.foo221- ./one/b.foo222- ./one/two/c.foo",220+ "a.foo221+ one/b.foo222+ one/two/c.foo",223 );224 }225 226 /// Smart case2 unmodified lines229 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);230 231 te.assert_output(232 &["c.foo"],233- "./one/two/c.foo234- ./one/two/C.Foo2",233+ "one/two/c.foo234+ one/two/C.Foo2",235 );236 237- te.assert_output(&["C.Foo"], "./one/two/C.Foo2");237+ te.assert_output(&["C.Foo"], "one/two/C.Foo2");238 239- te.assert_output(&["Foo"], "./one/two/C.Foo2");239+ te.assert_output(&["Foo"], "one/two/C.Foo2");240 241 // Only literal uppercase chars should trigger case sensitivity.242 te.assert_output(243 &["\\Ac"],244- "./one/two/c.foo245- ./one/two/C.Foo2",244+ "one/two/c.foo245+ one/two/C.Foo2",246 );247- te.assert_output(&["\\AC"], "./one/two/C.Foo2");247+ te.assert_output(&["\\AC"], "one/two/C.Foo2");248 }249 250 /// Case sensitivity (--case-sensitive)251 #[test]252 fn test_case_sensitive() {253 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);254 255- te.assert_output(&["--case-sensitive", "c.foo"], "./one/two/c.foo");255+ te.assert_output(&["--case-sensitive", "c.foo"], "one/two/c.foo");256 257- te.assert_output(&["--case-sensitive", "C.Foo"], "./one/two/C.Foo2");257+ te.assert_output(&["--case-sensitive", "C.Foo"], "one/two/C.Foo2");258 259 te.assert_output(260 &["--ignore-case", "--case-sensitive", "C.Foo"],261- "./one/two/C.Foo2",261+ "one/two/C.Foo2",262 );263 }264 265 /// Case insensitivity (--ignore-case)2 unmodified lines268 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);269 270 te.assert_output(271 &["--ignore-case", "C.Foo"],272- "./one/two/c.foo273- ./one/two/C.Foo2",272+ "one/two/c.foo273+ one/two/C.Foo2",274 );275 276 te.assert_output(277 &["--case-sensitive", "--ignore-case", "C.Foo"],278- "./one/two/c.foo279- ./one/two/C.Foo2",278+ "one/two/c.foo279+ one/two/C.Foo2",280 );281 }282 283 /// Glob-based searches (--glob)2 unmodified lines286 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);287 288 te.assert_output(289 &["--glob", "*.foo"],290- "./a.foo291- ./one/b.foo292- ./one/two/c.foo293- ./one/two/three/d.foo",290+ "a.foo291+ one/b.foo292+ one/two/c.foo293+ one/two/three/d.foo",294 );295 296 te.assert_output(297 &["--glob", "[a-c].foo"],298- "./a.foo299- ./one/b.foo300- ./one/two/c.foo",298+ "a.foo299+ one/b.foo300+ one/two/c.foo",301 );302 303 te.assert_output(304 &["--glob", "[a-c].foo*"],305- "./a.foo306- ./one/b.foo307- ./one/two/C.Foo2308- ./one/two/c.foo",305+ "a.foo306+ one/b.foo307+ one/two/C.Foo2308+ one/two/c.foo",309 );310 }311 312 /// Glob-based searches (--glob) in combination with full path searches (--full-path)3 unmodified lines316 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);317 318 te.assert_output(319 &["--glob", "--full-path", "**/one/**/*.foo"],320- "./one/b.foo321- ./one/two/c.foo322- ./one/two/three/d.foo",320+ "one/b.foo321+ one/two/c.foo322+ one/two/three/d.foo",323 );324 325 te.assert_output(326 &["--glob", "--full-path", "**/one/*/*.foo"],327- " ./one/two/c.foo",327+ " one/two/c.foo",328 );329 330 te.assert_output(331 &["--glob", "--full-path", "**/one/*/*/*.foo"],332- " ./one/two/three/d.foo",332+ " one/two/three/d.foo",333 );334 }335 336 #[test]1 unmodified line338 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);339 340 te.assert_output(341 &["--glob", "c.foo*"],342- "./one/two/C.Foo2343- ./one/two/c.foo",342+ "one/two/C.Foo2343+ one/two/c.foo",344 );345 346- te.assert_output(&["--glob", "C.Foo*"], "./one/two/C.Foo2");346+ te.assert_output(&["--glob", "C.Foo*"], "one/two/C.Foo2");347 }348 349 /// Glob-based searches (--glob) in combination with --case-sensitive350 #[test]351 fn test_case_sensitive_glob_searches() {352 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);353 354- te.assert_output(&["--glob", "--case-sensitive", "c.foo*"], "./one/two/c.foo");354+ te.assert_output(&["--glob", "--case-sensitive", "c.foo*"], "one/two/c.foo");355 }356 357 /// Glob-based searches (--glob) in combination with --extension358 #[test]1 unmodified line360 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);361 362 te.assert_output(363 &["--glob", "--extension", "foo2", "[a-z].*"],364- "./one/two/C.Foo2",364+ "one/two/C.Foo2",365 );366 }367 368 /// Make sure that --regex overrides --glob369 #[test]370 fn test_regex_overrides_glob() {371 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);372 373- te.assert_output(&["--glob", "--regex", "Foo2$"], "./one/two/C.Foo2");373+ te.assert_output(&["--glob", "--regex", "Foo2$"], "one/two/C.Foo2");374 }375 376 /// Full path search (--full-path)377 #[test]7 unmodified lines385 &[386 "--full-path",387 &format!("^{prefix}.*three.*foo$", prefix = prefix),388 ],389- "./one/two/three/d.foo390- ./one/two/three/directory_foo/",389+ "one/two/three/d.foo390+ one/two/three/directory_foo/",391 );392 }393 394 /// Hidden files (--hidden)2 unmodified lines397 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);398 399 te.assert_output(400 &["--hidden", "foo"],401- "./.hidden.foo402- ./a.foo403- ./one/b.foo404- ./one/two/c.foo405- ./one/two/C.Foo2406- ./one/two/three/d.foo407- ./one/two/three/directory_foo/",401+ ".hidden.foo402+ a.foo403+ one/b.foo404+ one/two/c.foo405+ one/two/C.Foo2406+ one/two/three/d.foo407+ one/two/three/directory_foo/",408 );409 }410 411 /// Hidden file attribute on Windows13 unmodified lines425 .attributes(FILE_ATTRIBUTE_HIDDEN)426 .open(te.test_root().join("hidden-file.txt"))427 .unwrap();428 429- te.assert_output(&["--hidden", "hidden-file.txt"], "./hidden-file.txt");429+ te.assert_output(&["--hidden", "hidden-file.txt"], "hidden-file.txt");430 te.assert_output(&["hidden-file.txt"], "");431 }432 433 /// Ignored files (--no-ignore)2 unmodified lines436 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);437 438 te.assert_output(439 &["--no-ignore", "foo"],440- "./a.foo441- ./fdignored.foo442- ./gitignored.foo443- ./one/b.foo444- ./one/two/c.foo445- ./one/two/C.Foo2446- ./one/two/three/d.foo447- ./one/two/three/directory_foo/",440+ "a.foo441+ fdignored.foo442+ gitignored.foo443+ one/b.foo444+ one/two/c.foo445+ one/two/C.Foo2446+ one/two/three/d.foo447+ one/two/three/directory_foo/",448 );449 450 te.assert_output(451 &["--hidden", "--no-ignore", "foo"],452- "./.hidden.foo453- ./a.foo454- ./fdignored.foo455- ./gitignored.foo456- ./one/b.foo457- ./one/two/c.foo458- ./one/two/C.Foo2459- ./one/two/three/d.foo460- ./one/two/three/directory_foo/",452+ ".hidden.foo453+ a.foo454+ fdignored.foo455+ gitignored.foo456+ one/b.foo457+ one/two/c.foo458+ one/two/C.Foo2459+ one/two/three/d.foo460+ one/two/three/directory_foo/",461 );462 }463 464 /// .gitignore and .fdignore16 unmodified lines481 .unwrap()482 .write_all(b"ignored-by-gitignore\nignored-by-both")483 .unwrap();484 485- te.assert_output(&["ignored"], "./ignored-by-nothing");485+ te.assert_output(&["ignored"], "ignored-by-nothing");486 487 te.assert_output(488 &["--no-ignore-vcs", "ignored"],489- "./ignored-by-nothing490- ./ignored-by-gitignore",489+ "ignored-by-nothing490+ ignored-by-gitignore",491 );492 493 te.assert_output(494 &["--no-ignore", "ignored"],495- "./ignored-by-nothing496- ./ignored-by-fdignore497- ./ignored-by-gitignore498- ./ignored-by-both",495+ "ignored-by-nothing496+ ignored-by-fdignore497+ ignored-by-gitignore498+ ignored-by-both",499 );500 }501 502 /// Ignore parent ignore files (--no-ignore-parent)17 unmodified lines520 .unwrap()521 .write_all(b"child-ignored")522 .unwrap();523 524- te.assert_output_subdirectory("inner", &[], "./not-ignored");524+ te.assert_output_subdirectory("inner", &[], "not-ignored");525 526 te.assert_output_subdirectory(527 "inner",528 &["--no-ignore-parent"],529- "./parent-ignored530- ./not-ignored",529+ "parent-ignored530+ not-ignored",531 );532 }533 534 /// Ignore parent ignore files (--no-ignore-parent) with an inner git repo23 unmodified lines558 559 te.assert_output_subdirectory(560 "inner",561 &[],562- "./not-ignored563- ./parent-ignored",562+ "not-ignored563+ parent-ignored",564 );565 566 te.assert_output_subdirectory(567 "inner",568 &["--no-ignore-parent"],569- "./not-ignored570- ./parent-ignored",569+ "not-ignored570+ parent-ignored",571 );572 }573 574 /// Precedence of .fdignore files14 unmodified lines589 .unwrap()590 .write_all(b"!foo")591 .unwrap();592 593- te.assert_output(&["foo"], "./inner/foo");593+ te.assert_output(&["foo"], "inner/foo");594 595- te.assert_output(&["--no-ignore-vcs", "foo"], "./inner/foo");595+ te.assert_output(&["--no-ignore-vcs", "foo"], "inner/foo");596 597- te.assert_output(&["--no-ignore", "foo"], "./inner/foo");597+ te.assert_output(&["--no-ignore", "foo"], "inner/foo");598 }599 600 /// VCS ignored files (--no-ignore-vcs)601 #[test]1 unmodified line603 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);604 605 te.assert_output(606 &["--no-ignore-vcs", "foo"],607- "./a.foo608- ./gitignored.foo609- ./one/b.foo610- ./one/two/c.foo611- ./one/two/C.Foo2612- ./one/two/three/d.foo613- ./one/two/three/directory_foo/",607+ "a.foo608+ gitignored.foo609+ one/b.foo610+ one/two/c.foo611+ one/two/C.Foo2612+ one/two/three/d.foo613+ one/two/three/directory_foo/",614 );615 }616 617 /// Test that --no-ignore-vcs still respects .fdignored in parent directory6 unmodified lines624 625 te.assert_output_subdirectory(626 "inner",627 &["--no-ignore-vcs", "foo"],628- "./foo629- ./gitignored.foo",628+ "foo629+ gitignored.foo",630 );631 }632 633 /// Custom ignore files (--ignore-file)8 unmodified lines642 .unwrap();643 644 te.assert_output(645 &["--ignore-file", "custom.ignore", "foo"],646- "./a.foo647- ./one/b.foo648- ./one/two/c.foo",646+ "a.foo647+ one/b.foo648+ one/two/c.foo",649 );650 }651 652 /// Ignored files with ripgrep aliases (-u / -uu)2 unmodified lines655 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);656 657 te.assert_output(658 &["-u", "foo"],659- "./.hidden.foo660- ./a.foo661- ./fdignored.foo662- ./gitignored.foo663- ./one/b.foo664- ./one/two/c.foo665- ./one/two/C.Foo2666- ./one/two/three/d.foo667- ./one/two/three/directory_foo/",659+ ".hidden.foo660+ a.foo661+ fdignored.foo662+ gitignored.foo663+ one/b.foo664+ one/two/c.foo665+ one/two/C.Foo2666+ one/two/three/d.foo667+ one/two/three/directory_foo/",668 );669 }670 671 /// Symlinks (--follow)2 unmodified lines674 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);675 676 te.assert_output(677 &["--follow", "c.foo"],678- "./one/two/c.foo679- ./one/two/C.Foo2680- ./symlink/c.foo681- ./symlink/C.Foo2",678+ "one/two/c.foo679+ one/two/C.Foo2680+ symlink/c.foo681+ symlink/C.Foo2",682 );683 }684 685 // File system boundaries (--one-file-system)46 unmodified lines732 .expect("Failed to create broken symlink.");733 734 te.assert_output(735 &["symlink"],736- "./broken_symlink737- ./symlink",736+ "broken_symlink737+ symlink",738 );739 te.assert_output(740 &["--type", "symlink", "symlink"],741- "./broken_symlink742- ./symlink",741+ "broken_symlink742+ symlink",743 );744 745 te.assert_output(&["--type", "file", "symlink"], "");746 747 te.assert_output(748 &["--follow", "--type", "symlink", "symlink"],749- "./broken_symlink",749+ "broken_symlink",750 );751 te.assert_output(&["--follow", "--type", "file", "symlink"], "");752 }753 19 unmodified lines773 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);774 775 te.assert_output(776 &["--max-depth", "3"],777- "./a.foo778- ./e1 e2779- ./one/780- ./one/b.foo781- ./one/two/782- ./one/two/c.foo783- ./one/two/C.Foo2784- ./one/two/three/785- ./symlink",777+ "a.foo778+ e1 e2779+ one/780+ one/b.foo781+ one/two/782+ one/two/c.foo783+ one/two/C.Foo2784+ one/two/three/785+ symlink",786 );787 788 te.assert_output(789 &["--max-depth", "2"],790- "./a.foo791- ./e1 e2792- ./one/793- ./one/b.foo794- ./one/two/795- ./symlink",790+ "a.foo791+ e1 e2792+ one/793+ one/b.foo794+ one/two/795+ symlink",796 );797 798 te.assert_output(799 &["--max-depth", "1"],800- "./a.foo801- ./e1 e2802- ./one/803- ./symlink",800+ "a.foo801+ e1 e2802+ one/803+ symlink",804 );805 }806 807 /// Minimum depth (--min-depth)2 unmodified lines810 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);811 812 te.assert_output(813 &["--min-depth", "3"],814- "./one/two/c.foo815- ./one/two/C.Foo2816- ./one/two/three/817- ./one/two/three/d.foo818- ./one/two/three/directory_foo/",814+ "one/two/c.foo815+ one/two/C.Foo2816+ one/two/three/817+ one/two/three/d.foo818+ one/two/three/directory_foo/",819 );820 821 te.assert_output(822 &["--min-depth", "4"],823- "./one/two/three/d.foo824- ./one/two/three/directory_foo/",823+ "one/two/three/d.foo824+ one/two/three/directory_foo/",825 );826 }827 828 /// Exact depth (--exact-depth)2 unmodified lines831 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);832 833 te.assert_output(834 &["--exact-depth", "3"],835- "./one/two/c.foo836- ./one/two/C.Foo2837- ./one/two/three/",835+ "one/two/c.foo836+ one/two/C.Foo2837+ one/two/three/",838 );839 }840 841 /// Pruning (--prune)842 #[test]843 fn test_prune() {844 let dirs = &["foo/bar", "bar/foo", "baz"];845 let files = &[846- "./foo/foo.file",847- "./foo/bar/foo.file",848- "./bar/foo.file",849- "./bar/foo/foo.file",850- "./baz/foo.file",846+ "foo/foo.file",847+ "foo/bar/foo.file",848+ "bar/foo.file",849+ "bar/foo/foo.file",850+ "baz/foo.file",851 ];852 853 let te = TestEnv::new(dirs, files);854 855 te.assert_output(856 &["foo"],857- "./foo/858- ./foo/foo.file859- ./foo/bar/foo.file860- ./bar/foo.file861- ./bar/foo/862- ./bar/foo/foo.file863- ./baz/foo.file",857+ "foo/858+ foo/foo.file859+ foo/bar/foo.file860+ bar/foo.file861+ bar/foo/862+ bar/foo/foo.file863+ baz/foo.file",864 );865 866 te.assert_output(867 &["--prune", "foo"],868- "./foo/869- ./bar/foo/870- ./bar/foo.file871- ./baz/foo.file",868+ "foo/869+ bar/foo/870+ bar/foo.file871+ baz/foo.file",872 );873 }874 875 /// Absolute paths (--absolute-path)78 unmodified lines954 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);955 956 te.assert_output(957 &["--type", "f"],958- "./a.foo959- ./e1 e2960- ./one/b.foo961- ./one/two/c.foo962- ./one/two/C.Foo2963- ./one/two/three/d.foo",958+ "a.foo959+ e1 e2960+ one/b.foo961+ one/two/c.foo962+ one/two/C.Foo2963+ one/two/three/d.foo",964 );965 966- te.assert_output(&["--type", "f", "e1"], "./e1 e2");966+ te.assert_output(&["--type", "f", "e1"], "e1 e2");967 968 te.assert_output(969 &["--type", "d"],970- "./one/971- ./one/two/972- ./one/two/three/973- ./one/two/three/directory_foo/",970+ "one/971+ one/two/972+ one/two/three/973+ one/two/three/directory_foo/",974 );975 976 te.assert_output(977 &["--type", "d", "--type", "l"],978- "./one/979- ./one/two/980- ./one/two/three/981- ./one/two/three/directory_foo/982- ./symlink",978+ "one/979+ one/two/980+ one/two/three/981+ one/two/three/directory_foo/982+ symlink",983 );984 985- te.assert_output(&["--type", "l"], "./symlink");985+ te.assert_output(&["--type", "l"], "symlink");986 }987 988 /// Test `--type executable`989 #[cfg(unix)]9 unmodified lines999 .mode(0o777)1000 .open(te.test_root().join("executable-file.sh"))1001 .unwrap();1002 1003- te.assert_output(&["--type", "executable"], "./executable-file.sh");1003+ te.assert_output(&["--type", "executable"], "executable-file.sh");1004 1005 te.assert_output(1006 &["--type", "executable", "--type", "directory"],1007- "./executable-file.sh1008- ./one/1009- ./one/two/1010- ./one/two/three/1011- ./one/two/three/directory_foo/",1007+ "executable-file.sh1008+ one/1009+ one/two/1010+ one/two/three/1011+ one/two/three/directory_foo/",1012 );1013 }1014 1015 /// Test `--type empty`7 unmodified lines1023 create_file_with_size(te.test_root().join("dir_nonempty").join("2_bytes.foo"), 2);1024 1025 te.assert_output(1026 &["--type", "empty"],1027- "./0_bytes.foo1028- ./dir_empty/",1027+ "0_bytes.foo1028+ dir_empty/",1029 );1030 1031 te.assert_output(1032 &["--type", "empty", "--type", "file", "--type", "directory"],1033- "./0_bytes.foo1034- ./dir_empty/",1033+ "0_bytes.foo1034+ dir_empty/",1035 );1036 1037- te.assert_output(&["--type", "empty", "--type", "file"], "./0_bytes.foo");1037+ te.assert_output(&["--type", "empty", "--type", "file"], "0_bytes.foo");1038 1039- te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty/");1039+ te.assert_output(&["--type", "empty", "--type", "directory"], "dir_empty/");1040 }1041 1042 /// File extension (--extension)1043 #[test]1 unmodified line1045 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);1046 1047 te.assert_output(1048 &["--extension", "foo"],1049- "./a.foo1050- ./one/b.foo1051- ./one/two/c.foo1052- ./one/two/three/d.foo",1049+ "a.foo1050+ one/b.foo1051+ one/two/c.foo1052+ one/two/three/d.foo",1053 );1054 1055 te.assert_output(1056 &["--extension", ".foo"],1057- "./a.foo1058- ./one/b.foo1059- ./one/two/c.foo1060- ./one/two/three/d.foo",1057+ "a.foo1058+ one/b.foo1059+ one/two/c.foo1060+ one/two/three/d.foo",1061 );1062 1063 te.assert_output(1064 &["--extension", ".foo", "--extension", "foo2"],1065- "./a.foo1066- ./one/b.foo1067- ./one/two/c.foo1068- ./one/two/three/d.foo1069- ./one/two/C.Foo2",1065+ "a.foo1066+ one/b.foo1067+ one/two/c.foo1068+ one/two/three/d.foo1069+ one/two/C.Foo2",1070 );1071 1072- te.assert_output(&["--extension", ".foo", "a"], "./a.foo");1072+ te.assert_output(&["--extension", ".foo", "a"], "a.foo");1073 1074- te.assert_output(&["--extension", "foo2"], "./one/two/C.Foo2");1074+ te.assert_output(&["--extension", "foo2"], "one/two/C.Foo2");1075 1076 let te2 = TestEnv::new(&[], &["spam.bar.baz", "egg.bar.baz", "yolk.bar.baz.sig"]);1077 1078 te2.assert_output(1079 &["--extension", ".bar.baz"],1080- "./spam.bar.baz1081- ./egg.bar.baz",1080+ "spam.bar.baz1081+ egg.bar.baz",1082 );1083 1084- te2.assert_output(&["--extension", "sig"], "./yolk.bar.baz.sig");1084+ te2.assert_output(&["--extension", "sig"], "yolk.bar.baz.sig");1085 1086- te2.assert_output(&["--extension", "bar.baz.sig"], "./yolk.bar.baz.sig");1086+ te2.assert_output(&["--extension", "bar.baz.sig"], "yolk.bar.baz.sig");1087 1088 let te3 = TestEnv::new(&[], &["latin1.e\u{301}xt", "smiley.☻"]);1089 1090- te3.assert_output(&["--extension", "☻"], "./smiley.☻");1090+ te3.assert_output(&["--extension", "☻"], "smiley.☻");1091 1092- te3.assert_output(&["--extension", ".e\u{301}xt"], "./latin1.e\u{301}xt");1092+ te3.assert_output(&["--extension", ".e\u{301}xt"], "latin1.e\u{301}xt");1093 1094 let te4 = TestEnv::new(&[], &[".hidden", "test.hidden"]);1095 1096- te4.assert_output(&["--hidden", "--extension", ".hidden"], "./test.hidden");1096+ te4.assert_output(&["--hidden", "--extension", ".hidden"], "test.hidden");1097 }1098 1099 /// No file extension (test for the pattern provided in the --help text)1100 #[test]4 unmodified lines1105 );1106 1107 te.assert_output(1108 &["^[^.]+$"],1109- "./aa1110- ./one/1111- ./one/bb1112- ./one/two/1113- ./one/two/three/1114- ./one/two/three/d1115- ./one/two/three/directory_foo/1116- ./symlink",1109+ "aa1110+ one/1111+ one/bb1112+ one/two/1113+ one/two/three/1114+ one/two/three/d1115+ one/two/three/directory_foo/1116+ symlink",1117 );1118 1119 te.assert_output(1120 &["^[^.]+$", "--type", "file"],1121- "./aa1122- ./one/bb1123- ./one/two/three/d",1121+ "aa1122+ one/bb1123+ one/two/three/d",1124 );1125 }1126 1127 /// Symlink as search directory126 unmodified lines1254 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);1255 1256 te.assert_output(1257 &["--exclude", "*.foo"],1258- "./one/1259- ./one/two/1260- ./one/two/C.Foo21261- ./one/two/three/1262- ./one/two/three/directory_foo/1263- ./e1 e21264- ./symlink",1258+ "one/1259+ one/two/1260+ one/two/C.Foo21261+ one/two/three/1262+ one/two/three/directory_foo/1263+ e1 e21264+ symlink",1265 );1266 1267 te.assert_output(1268 &["--exclude", "*.foo", "--exclude", "*.Foo2"],1269- "./one/1270- ./one/two/1271- ./one/two/three/1272- ./one/two/three/directory_foo/1273- ./e1 e21274- ./symlink",1269+ "one/1270+ one/two/1271+ one/two/three/1272+ one/two/three/directory_foo/1273+ e1 e21274+ symlink",1275 );1276 1277 te.assert_output(1278 &["--exclude", "*.foo", "--exclude", "*.Foo2", "foo"],1279- "./one/two/three/directory_foo/",1279+ "one/two/three/directory_foo/",1280 );1281 1282 te.assert_output(1283 &["--exclude", "one/two/", "foo"],1284- "./a.foo1285- ./one/b.foo",1284+ "a.foo1285+ one/b.foo",1286 );1287 1288 te.assert_output(1289 &["--exclude", "one/**/*.foo"],1290- "./a.foo1291- ./e1 e21292- ./one/1293- ./one/two/1294- ./one/two/C.Foo21295- ./one/two/three/1296- ./one/two/three/directory_foo/1297- ./symlink",1290+ "a.foo1291+ e1 e21292+ one/1293+ one/two/1294+ one/two/C.Foo21295+ one/two/three/1296+ one/two/three/directory_foo/1297+ symlink",1298 );1299 }1300 1301 /// Shell script execution (--exec)374 unmodified lines1676 1677 // Regex search, dot is treated as "any character"1678 te.assert_output(1679 &["a.foo"],1680- "./test1/a.foo1681- ./test1/a_foo",1680+ "test1/a.foo1681+ test1/a_foo",1682 );1683 1684 // Literal search, dot is treated as character1685- te.assert_output(&["--fixed-strings", "a.foo"], "./test1/a.foo");1685+ te.assert_output(&["--fixed-strings", "a.foo"], "test1/a.foo");1686 1687 // Regex search, parens are treated as group1688 te.assert_output(&["download (1)"], "");1689 1690 // Literal search, parens are treated as characters1691 te.assert_output(1692 &["--fixed-strings", "download (1)"],1693- "./test2/Download (1).tar.gz",1693+ "test2/Download (1).tar.gz",1694 );1695 1696 // Combine with --case-sensitive1697 te.assert_output(&["--fixed-strings", "--case-sensitive", "download (1)"], "");37 unmodified lines1735 1736 // Zero and non-zero sized files.1737 te.assert_output(1738 &["", "--size", "+0B"],1739- "./0_bytes.foo1740- ./11_bytes.foo1741- ./30_bytes.foo1742- ./3_kilobytes.foo1743- ./4_kibibytes.foo",1739+ "0_bytes.foo1740+ 11_bytes.foo1741+ 30_bytes.foo1742+ 3_kilobytes.foo1743+ 4_kibibytes.foo",1744 );1745 1746 // Zero sized files.1747- te.assert_output(&["", "--size", "-0B"], "./0_bytes.foo");1748- te.assert_output(&["", "--size", "0B"], "./0_bytes.foo");1749- te.assert_output(&["", "--size=0B"], "./0_bytes.foo");1750- te.assert_output(&["", "-S", "0B"], "./0_bytes.foo");1747+ te.assert_output(&["", "--size", "-0B"], "0_bytes.foo");1748+ te.assert_output(&["", "--size", "0B"], "0_bytes.foo");1749+ te.assert_output(&["", "--size=0B"], "0_bytes.foo");1750+ te.assert_output(&["", "-S", "0B"], "0_bytes.foo");1751 1752 // Files with 2 bytes or more.1753 te.assert_output(1754 &["", "--size", "+2B"],1755- "./11_bytes.foo1756- ./30_bytes.foo1757- ./3_kilobytes.foo1758- ./4_kibibytes.foo",1755+ "11_bytes.foo1756+ 30_bytes.foo1757+ 3_kilobytes.foo1758+ 4_kibibytes.foo",1759 );1760 1761 // Files with 2 bytes or less.1762- te.assert_output(&["", "--size", "-2B"], "./0_bytes.foo");1762+ te.assert_output(&["", "--size", "-2B"], "0_bytes.foo");1763 1764 // Files with size between 1 byte and 11 bytes.1765- te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "./11_bytes.foo");1765+ te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "11_bytes.foo");1766 1767 // Files with size equal 11 bytes.1768- te.assert_output(&["", "--size", "11B"], "./11_bytes.foo");1768+ te.assert_output(&["", "--size", "11B"], "11_bytes.foo");1769 1770 // Files with size between 1 byte and 30 bytes.1771 te.assert_output(1772 &["", "--size", "+1B", "--size", "-30B"],1773- "./11_bytes.foo1774- ./30_bytes.foo",1773+ "11_bytes.foo1774+ 30_bytes.foo",1775 );1776 1777 // Combine with a search pattern1778- te.assert_output(1779- &["^11_", "--size", "+1B", "--size", "-30B"],1780- "./11_bytes.foo",1781- );1778+ te.assert_output(&["^11_", "--size", "+1B", "--size", "-30B"], "11_bytes.foo");1779 1780 // Files with size between 12 and 30 bytes.1784- te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "./30_bytes.foo");1781+ te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "30_bytes.foo");1782 1783 // Files with size between 31 and 100 bytes.1784 te.assert_output(&["", "--size", "+31B", "--size", "-100B"], "");1785 1786 // Files with size between 3 kibibytes and 5 kibibytes.1790- te.assert_output(1791- &["", "--size", "+3ki", "--size", "-5ki"],1792- "./4_kibibytes.foo",1793- );1787+ te.assert_output(&["", "--size", "+3ki", "--size", "-5ki"], "4_kibibytes.foo");1788 1789 // Files with size between 3 kilobytes and 5 kilobytes.1790 te.assert_output(1791 &["", "--size", "+3k", "--size", "-5k"],1798- "./3_kilobytes.foo1799- ./4_kibibytes.foo",1792+ "3_kilobytes.foo1793+ 4_kibibytes.foo",1794 );1795 1796 // Files with size greater than 3 kilobytes and less than 3 kibibytes.1803- te.assert_output(1804- &["", "--size", "+3k", "--size", "-3ki"],1805- "./3_kilobytes.foo",1806- );1797+ te.assert_output(&["", "--size", "+3k", "--size", "-3ki"], "3_kilobytes.foo");1798 1799 // Files with size equal 4 kibibytes.1809- te.assert_output(1810- &["", "--size", "+4ki", "--size", "-4ki"],1811- "./4_kibibytes.foo",1812- );1813- te.assert_output(&["", "--size", "4ki"], "./4_kibibytes.foo");1800+ te.assert_output(&["", "--size", "+4ki", "--size", "-4ki"], "4_kibibytes.foo");1801+ te.assert_output(&["", "--size", "4ki"], "4_kibibytes.foo");1802 }1803 1804 #[cfg(test)]1805 fn create_file_with_modified<P: AsRef<Path>>(path: P, duration_in_secs: u64) {27 unmodified lines1833 create_file_with_modified(te.test_root().join("bar_1_day"), 24 * 60 * 60);1834 1835 te.assert_output(1836 &["", "--changed-within", "15min"],1849- "./foo_0_now1850- ./bar_1_min1851- ./foo_10_min",1837+ "foo_0_now1838+ bar_1_min1839+ foo_10_min",1840 );1841 1842 te.assert_output(1843 &["", "--change-older-than", "15min"],1856- "./bar_1_h1857- ./foo_2_h1858- ./bar_1_day",1844+ "bar_1_h1845+ foo_2_h1846+ bar_1_day",1847 );1848 1849 te.assert_output(1850 &["foo", "--changed-within", "12h"],1863- "./foo_0_now1864- ./foo_10_min1865- ./foo_2_h",1851+ "foo_0_now1852+ foo_10_min1853+ foo_2_h",1854 );1855 }1856 1857 #[cfg(test)]11 unmodified lines1869 change_file_modified(te.test_root().join("30dec2017"), "2017-12-30T23:59:00Z");1870 1871 te.assert_output(1872 &["", "--change-newer-than", "2018-01-01 00:00:00"],1885- "./15mar2018",1873+ "15mar2018",1874 );1875 te.assert_output(1876 &["", "--changed-before", "2018-01-01 00:00:00"],1889- "./30dec2017",1877+ "30dec2017",1878 );1879 }1880 1881 #[test]15 unmodified lines1897 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);1898 1899 te.assert_output(1900 &["--base-directory", "one"],1913- "./b.foo1914- ./two/1915- ./two/c.foo1916- ./two/C.Foo21917- ./two/three/1918- ./two/three/d.foo1919- ./two/three/directory_foo/",1901+ "b.foo1902+ two/1903+ two/c.foo1904+ two/C.Foo21905+ two/three/1906+ two/three/d.foo1907+ two/three/directory_foo/",1908 );1909 1910 te.assert_output(1911 &["--base-directory", "one/two/", "foo"],1924- "./c.foo1925- ./C.Foo21926- ./three/d.foo1927- ./three/directory_foo/",1912+ "c.foo1913+ C.Foo21914+ three/d.foo1915+ three/directory_foo/",1916 );1917 1918 // Explicit root path1919 te.assert_output(27 unmodified lines1947 1948 // Unrestricted1949 te.assert_output(1950 &["--max-results=0", "c.foo"],1963- "./one/two/C.Foo21964- ./one/two/c.foo",1951+ "one/two/C.Foo21952+ one/two/c.foo",1953 );1954 1955 // Limited to two results1956 te.assert_output(1957 &["--max-results=2", "c.foo"],1970- "./one/two/C.Foo21971- ./one/two/c.foo",1958+ "one/two/C.Foo21959+ one/two/c.foo",1960 );1961 1962 // Limited to one result. We could find either C.Foo2 or c.foo1963 let assert_just_one_result_with_option = |option| {1964 let output = te.assert_success_and_get_output(".", &[option, "c.foo"]);1965 let stdout = String::from_utf8_lossy(&output.stdout)1966 .trim()1967 .replace(&std::path::MAIN_SEPARATOR.to_string(), "/");1980- assert!(stdout == "./one/two/C.Foo2" || stdout == "./one/two/c.foo");1968+ assert!(stdout == "one/two/C.Foo2" || stdout == "one/two/c.foo");1969 };1970 assert_just_one_result_with_option("--max-results=1");1971 assert_just_one_result_with_option("-1");1972 }104 unmodified lines2077 2078 te.assert_failure(&["^\\.gitignore"]);2079 te.assert_failure(&["--glob", ".gitignore"]);2080 2093- te.assert_output(&["--hidden", "^\\.gitignore"], "./.gitignore");2094- te.assert_output(&["--hidden", "--glob", ".gitignore"], "./.gitignore");2081+ te.assert_output(&["--hidden", "^\\.gitignore"], ".gitignore");2082+ te.assert_output(&["--hidden", "--glob", ".gitignore"], ".gitignore");2083 te.assert_output(&[".gitignore"], "");2084 }2085 2086 #[test]41 unmodified lines