From b9cb5d54a4c7ed5be1fb2c179eb9bd38d3a7b4b5 Mon Sep 17 00:00:00 2001 From: Jonah Caplan Date: Sat, 16 Oct 2021 23:12:56 -0400 Subject: [PATCH] fixup tests --- tests/tests.rs | 740 +++++++++++++++++++++++++------------------------ 1 file changed, 376 insertions(+), 364 deletions(-) diff --git a/tests/tests.rs b/tests/tests.rs index d873f84..8811bf5 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -60,18 +60,18 @@ fn create_file_with_size>(path: P, size_in_bytes: usize) { fn test_simple() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["a.foo"], "a.foo"); - te.assert_output(&["b.foo"], "one/b.foo"); - te.assert_output(&["d.foo"], "one/two/three/d.foo"); + te.assert_output(&["a.foo"], "./a.foo"); + te.assert_output(&["b.foo"], "./one/b.foo"); + te.assert_output(&["d.foo"], "./one/two/three/d.foo"); te.assert_output( &["foo"], - "a.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -79,17 +79,17 @@ fn test_simple() { #[test] fn test_empty_pattern() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - let expected = "a.foo - e1 e2 - one - one/b.foo - one/two - one/two/c.foo - one/two/C.Foo2 - one/two/three - one/two/three/d.foo - one/two/three/directory_foo - symlink"; + let expected = "./a.foo + ./e1 e2 + ./one + ./one/b.foo + ./one/two + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three + ./one/two/three/d.foo + ./one/two/three/directory_foo + ./symlink"; te.assert_output(&["--regex"], expected); te.assert_output(&["--fixed-strings"], expected); @@ -208,17 +208,17 @@ fn test_regex_searches() { te.assert_output( &["[a-c].foo"], - "a.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2", + "./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2", ); te.assert_output( &["--case-sensitive", "[a-c].foo"], - "a.foo - one/b.foo - one/two/c.foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo", ); } @@ -229,21 +229,21 @@ fn test_smart_case() { te.assert_output( &["c.foo"], - "one/two/c.foo - one/two/C.Foo2", + "./one/two/c.foo + ./one/two/C.Foo2", ); - te.assert_output(&["C.Foo"], "one/two/C.Foo2"); + te.assert_output(&["C.Foo"], "./one/two/C.Foo2"); - te.assert_output(&["Foo"], "one/two/C.Foo2"); + te.assert_output(&["Foo"], "./one/two/C.Foo2"); // Only literal uppercase chars should trigger case sensitivity. te.assert_output( &["\\Ac"], - "one/two/c.foo - one/two/C.Foo2", + "./one/two/c.foo + ./one/two/C.Foo2", ); - te.assert_output(&["\\AC"], "one/two/C.Foo2"); + te.assert_output(&["\\AC"], "./one/two/C.Foo2"); } /// Case sensitivity (--case-sensitive) @@ -251,13 +251,13 @@ fn test_smart_case() { fn test_case_sensitive() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["--case-sensitive", "c.foo"], "one/two/c.foo"); + te.assert_output(&["--case-sensitive", "c.foo"], "./one/two/c.foo"); - te.assert_output(&["--case-sensitive", "C.Foo"], "one/two/C.Foo2"); + te.assert_output(&["--case-sensitive", "C.Foo"], "./one/two/C.Foo2"); te.assert_output( &["--ignore-case", "--case-sensitive", "C.Foo"], - "one/two/C.Foo2", + "./one/two/C.Foo2", ); } @@ -268,14 +268,14 @@ fn test_case_insensitive() { te.assert_output( &["--ignore-case", "C.Foo"], - "one/two/c.foo - one/two/C.Foo2", + "./one/two/c.foo + ./one/two/C.Foo2", ); te.assert_output( &["--case-sensitive", "--ignore-case", "C.Foo"], - "one/two/c.foo - one/two/C.Foo2", + "./one/two/c.foo + ./one/two/C.Foo2", ); } @@ -286,25 +286,25 @@ fn test_glob_searches() { te.assert_output( &["--glob", "*.foo"], - "a.foo - one/b.foo - one/two/c.foo - one/two/three/d.foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/three/d.foo", ); te.assert_output( &["--glob", "[a-c].foo"], - "a.foo - one/b.foo - one/two/c.foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo", ); te.assert_output( &["--glob", "[a-c].foo*"], - "a.foo - one/b.foo - one/two/C.Foo2 - one/two/c.foo", + "./a.foo + ./one/b.foo + ./one/two/C.Foo2 + ./one/two/c.foo", ); } @@ -316,19 +316,19 @@ fn test_full_path_glob_searches() { te.assert_output( &["--glob", "--full-path", "**/one/**/*.foo"], - "one/b.foo - one/two/c.foo - one/two/three/d.foo", + "./one/b.foo + ./one/two/c.foo + ./one/two/three/d.foo", ); te.assert_output( &["--glob", "--full-path", "**/one/*/*.foo"], - " one/two/c.foo", + " ./one/two/c.foo", ); te.assert_output( &["--glob", "--full-path", "**/one/*/*/*.foo"], - " one/two/three/d.foo", + " ./one/two/three/d.foo", ); } @@ -338,11 +338,11 @@ fn test_smart_case_glob_searches() { te.assert_output( &["--glob", "c.foo*"], - "one/two/C.Foo2 - one/two/c.foo", + "./one/two/C.Foo2 + ./one/two/c.foo", ); - te.assert_output(&["--glob", "C.Foo*"], "one/two/C.Foo2"); + te.assert_output(&["--glob", "C.Foo*"], "./one/two/C.Foo2"); } /// Glob-based searches (--glob) in combination with --case-sensitive @@ -350,7 +350,7 @@ fn test_smart_case_glob_searches() { fn test_case_sensitive_glob_searches() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["--glob", "--case-sensitive", "c.foo*"], "one/two/c.foo"); + te.assert_output(&["--glob", "--case-sensitive", "c.foo*"], "./one/two/c.foo"); } /// Glob-based searches (--glob) in combination with --extension @@ -360,7 +360,7 @@ fn test_glob_searches_with_extension() { te.assert_output( &["--glob", "--extension", "foo2", "[a-z].*"], - "one/two/C.Foo2", + "./one/two/C.Foo2", ); } @@ -369,7 +369,7 @@ fn test_glob_searches_with_extension() { fn test_regex_overrides_glob() { let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); - te.assert_output(&["--glob", "--regex", "Foo2$"], "one/two/C.Foo2"); + te.assert_output(&["--glob", "--regex", "Foo2$"], "./one/two/C.Foo2"); } /// Full path search (--full-path) @@ -385,8 +385,8 @@ fn test_full_path() { "--full-path", &format!("^{prefix}.*three.*foo$", prefix = prefix), ], - "one/two/three/d.foo - one/two/three/directory_foo", + "./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -397,13 +397,13 @@ fn test_hidden() { te.assert_output( &["--hidden", "foo"], - ".hidden.foo - a.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./.hidden.foo + ./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -425,7 +425,7 @@ fn test_hidden_file_attribute() { .open(te.test_root().join("hidden-file.txt")) .unwrap(); - te.assert_output(&["--hidden", "hidden-file.txt"], "hidden-file.txt"); + te.assert_output(&["--hidden", "hidden-file.txt"], "./hidden-file.txt"); te.assert_output(&["hidden-file.txt"], ""); } @@ -436,27 +436,27 @@ fn test_no_ignore() { te.assert_output( &["--no-ignore", "foo"], - "a.foo - fdignored.foo - gitignored.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./a.foo + ./fdignored.foo + ./gitignored.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); te.assert_output( &["--hidden", "--no-ignore", "foo"], - ".hidden.foo - a.foo - fdignored.foo - gitignored.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./.hidden.foo + ./a.foo + ./fdignored.foo + ./gitignored.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -481,20 +481,20 @@ fn test_gitignore_and_fdignore() { .write_all(b"ignored-by-gitignore\nignored-by-both") .unwrap(); - te.assert_output(&["ignored"], "ignored-by-nothing"); + te.assert_output(&["ignored"], "./ignored-by-nothing"); te.assert_output( &["--no-ignore-vcs", "ignored"], - "ignored-by-nothing - ignored-by-gitignore", + "./ignored-by-nothing + ./ignored-by-gitignore", ); te.assert_output( &["--no-ignore", "ignored"], - "ignored-by-nothing - ignored-by-fdignore - ignored-by-gitignore - ignored-by-both", + "./ignored-by-nothing + ./ignored-by-fdignore + ./ignored-by-gitignore + ./ignored-by-both", ); } @@ -520,13 +520,13 @@ fn test_no_ignore_parent() { .write_all(b"child-ignored") .unwrap(); - te.assert_output_subdirectory("inner", &[], "not-ignored"); + te.assert_output_subdirectory("inner", &[], "./not-ignored"); te.assert_output_subdirectory( "inner", &["--no-ignore-parent"], - "parent-ignored - not-ignored", + "./parent-ignored + ./not-ignored", ); } @@ -558,15 +558,15 @@ fn test_no_ignore_parent_inner_git() { te.assert_output_subdirectory( "inner", &[], - "not-ignored - parent-ignored", + "./not-ignored + ./parent-ignored", ); te.assert_output_subdirectory( "inner", &["--no-ignore-parent"], - "not-ignored - parent-ignored", + "./not-ignored + ./parent-ignored", ); } @@ -589,11 +589,11 @@ fn test_custom_ignore_precedence() { .write_all(b"!foo") .unwrap(); - te.assert_output(&["foo"], "inner/foo"); + te.assert_output(&["foo"], "./inner/foo"); - te.assert_output(&["--no-ignore-vcs", "foo"], "inner/foo"); + te.assert_output(&["--no-ignore-vcs", "foo"], "./inner/foo"); - te.assert_output(&["--no-ignore", "foo"], "inner/foo"); + te.assert_output(&["--no-ignore", "foo"], "./inner/foo"); } /// VCS ignored files (--no-ignore-vcs) @@ -603,13 +603,13 @@ fn test_no_ignore_vcs() { te.assert_output( &["--no-ignore-vcs", "foo"], - "a.foo - gitignored.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./a.foo + ./gitignored.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -626,9 +626,9 @@ fn test_custom_ignore_files() { te.assert_output( &["--ignore-file", "custom.ignore", "foo"], - "a.foo - one/b.foo - one/two/c.foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo", ); } @@ -639,27 +639,27 @@ fn test_no_ignore_aliases() { te.assert_output( &["-u", "foo"], - "a.foo - fdignored.foo - gitignored.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./a.foo + ./fdignored.foo + ./gitignored.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); te.assert_output( &["-uu", "foo"], - ".hidden.foo - a.foo - fdignored.foo - gitignored.foo - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo - one/two/three/directory_foo", + "./.hidden.foo + ./a.foo + ./fdignored.foo + ./gitignored.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -670,10 +670,10 @@ fn test_follow() { te.assert_output( &["--follow", "c.foo"], - "one/two/c.foo - one/two/C.Foo2 - symlink/c.foo - symlink/C.Foo2", + "./one/two/c.foo + ./one/two/C.Foo2 + ./symlink/c.foo + ./symlink/C.Foo2", ); } @@ -728,20 +728,20 @@ fn test_follow_broken_symlink() { te.assert_output( &["symlink"], - "broken_symlink - symlink", + "./broken_symlink + ./symlink", ); te.assert_output( &["--type", "symlink", "symlink"], - "broken_symlink - symlink", + "./broken_symlink + ./symlink", ); te.assert_output(&["--type", "file", "symlink"], ""); te.assert_output( &["--follow", "--type", "symlink", "symlink"], - "broken_symlink", + "./broken_symlink", ); te.assert_output(&["--follow", "--type", "file", "symlink"], ""); } @@ -753,12 +753,12 @@ fn test_print0() { te.assert_output( &["--print0", "foo"], - "a.fooNULL - one/b.fooNULL - one/two/C.Foo2NULL - one/two/c.fooNULL - one/two/three/d.fooNULL - one/two/three/directory_fooNULL", + "./a.fooNULL + ./one/b.fooNULL + ./one/two/C.Foo2NULL + ./one/two/c.fooNULL + ./one/two/three/d.fooNULL + ./one/two/three/directory_fooNULL", ); } @@ -769,33 +769,33 @@ fn test_max_depth() { te.assert_output( &["--max-depth", "3"], - "a.foo - e1 e2 - one - one/b.foo - one/two - one/two/c.foo - one/two/C.Foo2 - one/two/three - symlink", + "./a.foo + ./e1 e2 + ./one + ./one/b.foo + ./one/two + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three + ./symlink", ); te.assert_output( &["--max-depth", "2"], - "a.foo - e1 e2 - one - one/b.foo - one/two - symlink", + "./a.foo + ./e1 e2 + ./one + ./one/b.foo + ./one/two + ./symlink", ); te.assert_output( &["--max-depth", "1"], - "a.foo - e1 e2 - one - symlink", + "./a.foo + ./e1 e2 + ./one + ./symlink", ); } @@ -806,17 +806,17 @@ fn test_min_depth() { te.assert_output( &["--min-depth", "3"], - "one/two/c.foo - one/two/C.Foo2 - one/two/three - one/two/three/d.foo - one/two/three/directory_foo", + "./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); te.assert_output( &["--min-depth", "4"], - "one/two/three/d.foo - one/two/three/directory_foo", + "./one/two/three/d.foo + ./one/two/three/directory_foo", ); } @@ -827,9 +827,9 @@ fn test_exact_depth() { te.assert_output( &["--exact-depth", "3"], - "one/two/c.foo - one/two/C.Foo2 - one/two/three", + "./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three", ); } @@ -838,32 +838,32 @@ fn test_exact_depth() { fn test_prune() { let dirs = &["foo/bar", "bar/foo", "baz"]; let files = &[ - "foo/foo.file", - "foo/bar/foo.file", - "bar/foo.file", - "bar/foo/foo.file", - "baz/foo.file", + "./foo/foo.file", + "./foo/bar/foo.file", + "./bar/foo.file", + "./bar/foo/foo.file", + "./baz/foo.file", ]; let te = TestEnv::new(dirs, files); te.assert_output( &["foo"], - "foo - foo/foo.file - foo/bar/foo.file - bar/foo.file - bar/foo - bar/foo/foo.file - baz/foo.file", + "./foo + ./foo/foo.file + ./foo/bar/foo.file + ./bar/foo.file + ./bar/foo + ./bar/foo/foo.file + ./baz/foo.file", ); te.assert_output( &["--prune", "foo"], - "foo - bar/foo - bar/foo.file - baz/foo.file", + "./foo + ./bar/foo + ./bar/foo.file + ./baz/foo.file", ); } @@ -950,34 +950,34 @@ fn test_type() { te.assert_output( &["--type", "f"], - "a.foo - e1 e2 - one/b.foo - one/two/c.foo - one/two/C.Foo2 - one/two/three/d.foo", + "./a.foo + ./e1 e2 + ./one/b.foo + ./one/two/c.foo + ./one/two/C.Foo2 + ./one/two/three/d.foo", ); - te.assert_output(&["--type", "f", "e1"], "e1 e2"); + te.assert_output(&["--type", "f", "e1"], "./e1 e2"); te.assert_output( &["--type", "d"], - "one - one/two - one/two/three - one/two/three/directory_foo", + "./one + ./one/two + ./one/two/three + ./one/two/three/directory_foo", ); te.assert_output( &["--type", "d", "--type", "l"], - "one - one/two - one/two/three - one/two/three/directory_foo - symlink", + "./one + ./one/two + ./one/two/three + ./one/two/three/directory_foo + ./symlink", ); - te.assert_output(&["--type", "l"], "symlink"); + te.assert_output(&["--type", "l"], "./symlink"); } /// Test `--type executable` @@ -995,15 +995,15 @@ fn test_type_executable() { .open(te.test_root().join("executable-file.sh")) .unwrap(); - te.assert_output(&["--type", "executable"], "executable-file.sh"); + te.assert_output(&["--type", "executable"], "./executable-file.sh"); te.assert_output( &["--type", "executable", "--type", "directory"], - "executable-file.sh - one - one/two - one/two/three - one/two/three/directory_foo", + "./executable-file.sh + ./one + ./one/two + ./one/two/three + ./one/two/three/directory_foo", ); } @@ -1019,19 +1019,19 @@ fn test_type_empty() { te.assert_output( &["--type", "empty"], - "0_bytes.foo - dir_empty", + "./0_bytes.foo + ./dir_empty", ); te.assert_output( &["--type", "empty", "--type", "file", "--type", "directory"], - "0_bytes.foo - dir_empty", + "./0_bytes.foo + ./dir_empty", ); - te.assert_output(&["--type", "empty", "--type", "file"], "0_bytes.foo"); + te.assert_output(&["--type", "empty", "--type", "file"], "./0_bytes.foo"); - te.assert_output(&["--type", "empty", "--type", "directory"], "dir_empty"); + te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty"); } /// File extension (--extension) @@ -1041,54 +1041,54 @@ fn test_extension() { te.assert_output( &["--extension", "foo"], - "a.foo - one/b.foo - one/two/c.foo - one/two/three/d.foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/three/d.foo", ); te.assert_output( &["--extension", ".foo"], - "a.foo - one/b.foo - one/two/c.foo - one/two/three/d.foo", + "./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/three/d.foo", ); te.assert_output( &["--extension", ".foo", "--extension", "foo2"], - "a.foo - one/b.foo - one/two/c.foo - one/two/three/d.foo - one/two/C.Foo2", + "./a.foo + ./one/b.foo + ./one/two/c.foo + ./one/two/three/d.foo + ./one/two/C.Foo2", ); - te.assert_output(&["--extension", ".foo", "a"], "a.foo"); + te.assert_output(&["--extension", ".foo", "a"], "./a.foo"); - te.assert_output(&["--extension", "foo2"], "one/two/C.Foo2"); + te.assert_output(&["--extension", "foo2"], "./one/two/C.Foo2"); let te2 = TestEnv::new(&[], &["spam.bar.baz", "egg.bar.baz", "yolk.bar.baz.sig"]); te2.assert_output( &["--extension", ".bar.baz"], - "spam.bar.baz - egg.bar.baz", + "./spam.bar.baz + ./egg.bar.baz", ); - te2.assert_output(&["--extension", "sig"], "yolk.bar.baz.sig"); + te2.assert_output(&["--extension", "sig"], "./yolk.bar.baz.sig"); - te2.assert_output(&["--extension", "bar.baz.sig"], "yolk.bar.baz.sig"); + te2.assert_output(&["--extension", "bar.baz.sig"], "./yolk.bar.baz.sig"); let te3 = TestEnv::new(&[], &["latin1.e\u{301}xt", "smiley.☻"]); - te3.assert_output(&["--extension", "☻"], "smiley.☻"); + te3.assert_output(&["--extension", "☻"], "./smiley.☻"); - te3.assert_output(&["--extension", ".e\u{301}xt"], "latin1.e\u{301}xt"); + te3.assert_output(&["--extension", ".e\u{301}xt"], "./latin1.e\u{301}xt"); let te4 = TestEnv::new(&[], &[".hidden", "test.hidden"]); - te4.assert_output(&["--hidden", "--extension", ".hidden"], "test.hidden"); + te4.assert_output(&["--hidden", "--extension", ".hidden"], "./test.hidden"); } /// No file extension (test for the pattern provided in the --help text) @@ -1101,21 +1101,21 @@ fn test_no_extension() { te.assert_output( &["^[^.]+$"], - "aa - one - one/bb - one/two - one/two/three - one/two/three/d - one/two/three/directory_foo - symlink", + "./aa + ./one + ./one/bb + ./one/two + ./one/two/three + ./one/two/three/d + ./one/two/three/directory_foo + ./symlink", ); te.assert_output( &["^[^.]+$", "--type", "file"], - "aa - one/bb - one/two/three/d", + "./aa + ./one/bb + ./one/two/three/d", ); } @@ -1250,46 +1250,46 @@ fn test_excludes() { te.assert_output( &["--exclude", "*.foo"], - "one - one/two - one/two/C.Foo2 - one/two/three - one/two/three/directory_foo - e1 e2 - symlink", + "./one + ./one/two + ./one/two/C.Foo2 + ./one/two/three + ./one/two/three/directory_foo + ./e1 e2 + ./symlink", ); te.assert_output( &["--exclude", "*.foo", "--exclude", "*.Foo2"], - "one - one/two - one/two/three - one/two/three/directory_foo - e1 e2 - symlink", + "./one + ./one/two + ./one/two/three + ./one/two/three/directory_foo + ./e1 e2 + ./symlink", ); te.assert_output( &["--exclude", "*.foo", "--exclude", "*.Foo2", "foo"], - "one/two/three/directory_foo", + "./one/two/three/directory_foo", ); te.assert_output( &["--exclude", "one/two", "foo"], - "a.foo - one/b.foo", + "./a.foo + ./one/b.foo", ); te.assert_output( &["--exclude", "one/**/*.foo"], - "a.foo - e1 e2 - one - one/two - one/two/C.Foo2 - one/two/three - one/two/three/directory_foo - symlink", + "./a.foo + ./e1 e2 + ./one + ./one/two + ./one/two/C.Foo2 + ./one/two/three + ./one/two/three/directory_foo + ./symlink", ); } @@ -1314,12 +1314,12 @@ fn test_exec() { te.assert_output( &["foo", "--exec", "echo", "{}"], - "a.foo - one/b.foo - one/two/C.Foo2 - one/two/c.foo - one/two/three/d.foo - one/two/three/directory_foo", + "./a.foo + ./one/b.foo + ./one/two/C.Foo2 + ./one/two/c.foo + ./one/two/three/d.foo + ./one/two/three/directory_foo", ); te.assert_output( @@ -1355,14 +1355,14 @@ fn test_exec() { te.assert_output( &["foo", "--exec", "echo", "{//}"], ". - one - one/two - one/two - one/two/three - one/two/three", + ./one + ./one/two + ./one/two + ./one/two/three + ./one/two/three", ); - te.assert_output(&["e1", "--exec", "printf", "%s.%s\n"], "e1 e2."); + te.assert_output(&["e1", "--exec", "printf", "%s.%s\n"], "./e1 e2."); } } @@ -1383,7 +1383,7 @@ fn test_exec_batch() { te.assert_output( &["foo", "--exec-batch", "echo", "{}"], - "a.foo one/b.foo one/two/C.Foo2 one/two/c.foo one/two/three/d.foo one/two/three/directory_foo", + "./a.foo ./one/b.foo ./one/two/C.Foo2 ./one/two/c.foo ./one/two/three/d.foo ./one/two/three/directory_foo", ); te.assert_output( @@ -1443,12 +1443,12 @@ fn test_exec_with_separator() { te.assert_output( &["--path-separator=#", "foo", "--exec", "echo", "{}"], - "a.foo - one#b.foo - one#two#C.Foo2 - one#two#c.foo - one#two#three#d.foo - one#two#three#directory_foo", + ".#a.foo + .#one#b.foo + .#one#two#C.Foo2 + .#one#two#c.foo + .#one#two#three#d.foo + .#one#two#three#directory_foo", ); te.assert_output( @@ -1484,16 +1484,16 @@ fn test_exec_with_separator() { te.assert_output( &["--path-separator=#", "foo", "--exec", "echo", "{//}"], ". - one - one#two - one#two - one#two#three - one#two#three", + .#one + .#one#two + .#one#two + .#one#two#three + .#one#two#three", ); te.assert_output( &["--path-separator=#", "e1", "--exec", "printf", "%s.%s\n"], - "e1 e2.", + ".#e1 e2.", ); } @@ -1520,12 +1520,12 @@ fn test_fixed_strings() { // Regex search, dot is treated as "any character" te.assert_output( &["a.foo"], - "test1/a.foo - test1/a_foo", + "./test1/a.foo + ./test1/a_foo", ); // Literal search, dot is treated as character - te.assert_output(&["--fixed-strings", "a.foo"], "test1/a.foo"); + te.assert_output(&["--fixed-strings", "a.foo"], "./test1/a.foo"); // Regex search, parens are treated as group te.assert_output(&["download (1)"], ""); @@ -1533,7 +1533,7 @@ fn test_fixed_strings() { // Literal search, parens are treated as characters te.assert_output( &["--fixed-strings", "download (1)"], - "test2/Download (1).tar.gz", + "./test2/Download (1).tar.gz", ); // Combine with --case-sensitive @@ -1579,69 +1579,81 @@ fn test_size() { // Zero and non-zero sized files. te.assert_output( &["", "--size", "+0B"], - "0_bytes.foo - 11_bytes.foo - 30_bytes.foo - 3_kilobytes.foo - 4_kibibytes.foo", + "./0_bytes.foo + ./11_bytes.foo + ./30_bytes.foo + ./3_kilobytes.foo + ./4_kibibytes.foo", ); // Zero sized files. - te.assert_output(&["", "--size", "-0B"], "0_bytes.foo"); - te.assert_output(&["", "--size", "0B"], "0_bytes.foo"); - te.assert_output(&["", "--size=0B"], "0_bytes.foo"); - te.assert_output(&["", "-S", "0B"], "0_bytes.foo"); + te.assert_output(&["", "--size", "-0B"], "./0_bytes.foo"); + te.assert_output(&["", "--size", "0B"], "./0_bytes.foo"); + te.assert_output(&["", "--size=0B"], "./0_bytes.foo"); + te.assert_output(&["", "-S", "0B"], "./0_bytes.foo"); // Files with 2 bytes or more. te.assert_output( &["", "--size", "+2B"], - "11_bytes.foo - 30_bytes.foo - 3_kilobytes.foo - 4_kibibytes.foo", + "./11_bytes.foo + ./30_bytes.foo + ./3_kilobytes.foo + ./4_kibibytes.foo", ); // Files with 2 bytes or less. - te.assert_output(&["", "--size", "-2B"], "0_bytes.foo"); + te.assert_output(&["", "--size", "-2B"], "./0_bytes.foo"); // Files with size between 1 byte and 11 bytes. - te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "11_bytes.foo"); + te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "./11_bytes.foo"); // Files with size equal 11 bytes. - te.assert_output(&["", "--size", "11B"], "11_bytes.foo"); + te.assert_output(&["", "--size", "11B"], "./11_bytes.foo"); // Files with size between 1 byte and 30 bytes. te.assert_output( &["", "--size", "+1B", "--size", "-30B"], - "11_bytes.foo - 30_bytes.foo", + "./11_bytes.foo + ./30_bytes.foo", ); // Combine with a search pattern - te.assert_output(&["^11_", "--size", "+1B", "--size", "-30B"], "11_bytes.foo"); + te.assert_output( + &["^11_", "--size", "+1B", "--size", "-30B"], + "./11_bytes.foo", + ); // Files with size between 12 and 30 bytes. - te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "30_bytes.foo"); + te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "./30_bytes.foo"); // Files with size between 31 and 100 bytes. te.assert_output(&["", "--size", "+31B", "--size", "-100B"], ""); // Files with size between 3 kibibytes and 5 kibibytes. - te.assert_output(&["", "--size", "+3ki", "--size", "-5ki"], "4_kibibytes.foo"); + te.assert_output( + &["", "--size", "+3ki", "--size", "-5ki"], + "./4_kibibytes.foo", + ); // Files with size between 3 kilobytes and 5 kilobytes. te.assert_output( &["", "--size", "+3k", "--size", "-5k"], - "3_kilobytes.foo - 4_kibibytes.foo", + "./3_kilobytes.foo + ./4_kibibytes.foo", ); // Files with size greater than 3 kilobytes and less than 3 kibibytes. - te.assert_output(&["", "--size", "+3k", "--size", "-3ki"], "3_kilobytes.foo"); + te.assert_output( + &["", "--size", "+3k", "--size", "-3ki"], + "./3_kilobytes.foo", + ); // Files with size equal 4 kibibytes. - te.assert_output(&["", "--size", "+4ki", "--size", "-4ki"], "4_kibibytes.foo"); - te.assert_output(&["", "--size", "4ki"], "4_kibibytes.foo"); + te.assert_output( + &["", "--size", "+4ki", "--size", "-4ki"], + "./4_kibibytes.foo", + ); + te.assert_output(&["", "--size", "4ki"], "./4_kibibytes.foo"); } #[cfg(test)] @@ -1677,23 +1689,23 @@ fn test_modified_relative() { te.assert_output( &["", "--changed-within", "15min"], - "foo_0_now - bar_1_min - foo_10_min", + "./foo_0_now + ./bar_1_min + ./foo_10_min", ); te.assert_output( &["", "--change-older-than", "15min"], - "bar_1_h - foo_2_h - bar_1_day", + "./bar_1_h + ./foo_2_h + ./bar_1_day", ); te.assert_output( &["foo", "--changed-within", "12h"], - "foo_0_now - foo_10_min - foo_2_h", + "./foo_0_now + ./foo_10_min + ./foo_2_h", ); } @@ -1713,11 +1725,11 @@ fn test_modified_absolute() { te.assert_output( &["", "--change-newer-than", "2018-01-01 00:00:00"], - "15mar2018", + "./15mar2018", ); te.assert_output( &["", "--changed-before", "2018-01-01 00:00:00"], - "30dec2017", + "./30dec2017", ); } @@ -1741,21 +1753,21 @@ fn test_base_directory() { te.assert_output( &["--base-directory", "one"], - "b.foo - two - two/c.foo - two/C.Foo2 - two/three - two/three/d.foo - two/three/directory_foo", + "./b.foo + ./two + ./two/c.foo + ./two/C.Foo2 + ./two/three + ./two/three/d.foo + ./two/three/directory_foo", ); te.assert_output( &["--base-directory", "one/two", "foo"], - "c.foo - C.Foo2 - three/d.foo - three/directory_foo", + "./c.foo + ./C.Foo2 + ./three/d.foo + ./three/directory_foo", ); // Explicit root path @@ -1791,15 +1803,15 @@ fn test_max_results() { // Unrestricted te.assert_output( &["--max-results=0", "c.foo"], - "one/two/C.Foo2 - one/two/c.foo", + "./one/two/C.Foo2 + ./one/two/c.foo", ); // Limited to two results te.assert_output( &["--max-results=2", "c.foo"], - "one/two/C.Foo2 - one/two/c.foo", + "./one/two/C.Foo2 + ./one/two/c.foo", ); // Limited to one result. We could find either C.Foo2 or c.foo @@ -1808,7 +1820,7 @@ fn test_max_results() { let stdout = String::from_utf8_lossy(&output.stdout) .trim() .replace(&std::path::MAIN_SEPARATOR.to_string(), "/"); - assert!(stdout == "one/two/C.Foo2" || stdout == "one/two/c.foo"); + assert!(stdout == "./one/two/C.Foo2" || stdout == "./one/two/c.foo"); }; assert_just_one_result_with_option("--max-results=1"); assert_just_one_result_with_option("-1"); @@ -1897,8 +1909,8 @@ fn test_error_if_hidden_not_set_and_pattern_starts_with_dot() { te.assert_failure(&["^\\.gitignore"]); te.assert_failure(&["--glob", ".gitignore"]); - te.assert_output(&["--hidden", "^\\.gitignore"], ".gitignore"); - te.assert_output(&["--hidden", "--glob", ".gitignore"], ".gitignore"); + te.assert_output(&["--hidden", "^\\.gitignore"], "./.gitignore"); + te.assert_output(&["--hidden", "--glob", ".gitignore"], "./.gitignore"); te.assert_output(&[".gitignore"], ""); }