Skip to content
Myr

tests: fix for trailing slashes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jonathan Goren · committed by Jonathan Goren · parent a26bd32 · Browse files · 1 file+98 added−98 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+98 added−98 removed

  • tests:+98 added−98 removed

1 file+98 added−98 removed

modified:tests/tests.rs+98 added-98 removed
70 unmodified lines
71 ./one/b.foo72 ./one/two/c.foo73 ./one/two/C.Foo274 ./one/two/three/d.foo75 ./one/two/three/directory_foo",75 ./one/two/three/directory_foo/",76 );77}7879/// Test each pattern type with an empty pattern.
1 unmodified line
81fn test_empty_pattern() {82 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);83 let expected = "./a.foo84 ./e1 e285 ./one85 ./one/86 ./one/b.foo87 ./one/two87 ./one/two/88 ./one/two/c.foo89 ./one/two/C.Foo290 ./one/two/three90 ./one/two/three/91 ./one/two/three/d.foo92 ./one/two/three/directory_foo92 ./one/two/three/directory_foo/93 ./symlink";9495 te.assert_output(&["--regex"], expected);96 te.assert_output(&["--fixed-strings"], expected);
73 unmodified lines
170 "one/b.foo171 one/two/c.foo172 one/two/C.Foo2173 one/two/three/d.foo174 one/two/three/directory_foo",174 one/two/three/directory_foo/",175 );176177 te.assert_output(178 &["foo", "one/two/three"],179 "one/two/three/d.foo180 one/two/three/directory_foo",180 one/two/three/directory_foo/",181 );182183 te.assert_output_subdirectory(184 "one/two",184 "one/two/",185 &["foo", "../../"],186 "../../a.foo187 ../../one/b.foo188 ../../one/two/c.foo189 ../../one/two/C.Foo2190 ../../one/two/three/d.foo191 ../../one/two/three/directory_foo",191 ../../one/two/three/directory_foo/",192 );193194 te.assert_output_subdirectory(195 "one/two/three",196 &["", ".."],197 "../c.foo198 ../C.Foo2199 ../three199 ../three/200 ../three/d.foo201 ../three/directory_foo",201 ../three/directory_foo/",202 );203}204205/// Regex searches
180 unmodified lines
386 "--full-path",387 &format!("^{prefix}.*three.*foo$", prefix = prefix),388 ],389 "./one/two/three/d.foo390 ./one/two/three/directory_foo",390 ./one/two/three/directory_foo/",391 );392}393394/// Hidden files (--hidden)
8 unmodified lines
403 ./one/b.foo404 ./one/two/c.foo405 ./one/two/C.Foo2406 ./one/two/three/d.foo407 ./one/two/three/directory_foo",407 ./one/two/three/directory_foo/",408 );409}410411/// Hidden file attribute on Windows
31 unmodified lines
443 ./one/b.foo444 ./one/two/c.foo445 ./one/two/C.Foo2446 ./one/two/three/d.foo447 ./one/two/three/directory_foo",447 ./one/two/three/directory_foo/",448 );449450 te.assert_output(451 &["--hidden", "--no-ignore", "foo"],
4 unmodified lines
456 ./one/b.foo457 ./one/two/c.foo458 ./one/two/C.Foo2459 ./one/two/three/d.foo460 ./one/two/three/directory_foo",460 ./one/two/three/directory_foo/",461 );462}463464/// .gitignore and .fdignore
144 unmodified lines
609 ./one/b.foo610 ./one/two/c.foo611 ./one/two/C.Foo2612 ./one/two/three/d.foo613 ./one/two/three/directory_foo",613 ./one/two/three/directory_foo/",614 );615}616617/// Custom ignore files (--ignore-file)
28 unmodified lines
646 ./one/b.foo647 ./one/two/c.foo648 ./one/two/C.Foo2649 ./one/two/three/d.foo650 ./one/two/three/directory_foo",650 ./one/two/three/directory_foo/",651 );652653 te.assert_output(654 &["-uu", "foo"],
4 unmodified lines
659 ./one/b.foo660 ./one/two/c.foo661 ./one/two/C.Foo2662 ./one/two/three/d.foo663 ./one/two/three/directory_foo",663 ./one/two/three/directory_foo/",664 );665}666667/// Symlinks (--follow)
90 unmodified lines
758 ./one/b.fooNULL759 ./one/two/C.Foo2NULL760 ./one/two/c.fooNULL761 ./one/two/three/d.fooNULL762 ./one/two/three/directory_fooNULL",762 ./one/two/three/directory_foo/NULL",763 );764}765766/// Maximum depth (--max-depth)
4 unmodified lines
771 te.assert_output(772 &["--max-depth", "3"],773 "./a.foo774 ./e1 e2775 ./one775 ./one/776 ./one/b.foo777 ./one/two777 ./one/two/778 ./one/two/c.foo779 ./one/two/C.Foo2780 ./one/two/three780 ./one/two/three/781 ./symlink",782 );783784 te.assert_output(785 &["--max-depth", "2"],786 "./a.foo787 ./e1 e2788 ./one788 ./one/789 ./one/b.foo790 ./one/two790 ./one/two/791 ./symlink",792 );793794 te.assert_output(795 &["--max-depth", "1"],796 "./a.foo797 ./e1 e2798 ./one798 ./one/799 ./symlink",800 );801}802
5 unmodified lines
808 te.assert_output(809 &["--min-depth", "3"],810 "./one/two/c.foo811 ./one/two/C.Foo2812 ./one/two/three812 ./one/two/three/813 ./one/two/three/d.foo814 ./one/two/three/directory_foo",814 ./one/two/three/directory_foo/",815 );816817 te.assert_output(818 &["--min-depth", "4"],819 "./one/two/three/d.foo820 ./one/two/three/directory_foo",820 ./one/two/three/directory_foo/",821 );822}823824/// Exact depth (--exact-depth)
4 unmodified lines
829 te.assert_output(830 &["--exact-depth", "3"],831 "./one/two/c.foo832 ./one/two/C.Foo2833 ./one/two/three",833 ./one/two/three/",834 );835}836837/// Pruning (--prune)
11 unmodified lines
849 let te = TestEnv::new(dirs, files);850851 te.assert_output(852 &["foo"],853 "./foo853 "./foo/854 ./foo/foo.file855 ./foo/bar/foo.file856 ./bar/foo.file857 ./bar/foo857 ./bar/foo/858 ./bar/foo/foo.file859 ./baz/foo.file",860 );861862 te.assert_output(863 &["--prune", "foo"],864 "./foo865 ./bar/foo864 "./foo/865 ./bar/foo/866 ./bar/foo.file867 ./baz/foo.file",868 );869}
7 unmodified lines
877 &["--absolute-path"],878 &format!(879 "{abs_path}/a.foo880 {abs_path}/e1 e2881 {abs_path}/one881 {abs_path}/one/882 {abs_path}/one/b.foo883 {abs_path}/one/two883 {abs_path}/one/two/884 {abs_path}/one/two/c.foo885 {abs_path}/one/two/C.Foo2886 {abs_path}/one/two/three886 {abs_path}/one/two/three/887 {abs_path}/one/two/three/d.foo888 {abs_path}/one/two/three/directory_foo888 {abs_path}/one/two/three/directory_foo/889 {abs_path}/symlink",890 abs_path = &abs_path891 ),892 );
5 unmodified lines
898 {abs_path}/one/b.foo899 {abs_path}/one/two/c.foo900 {abs_path}/one/two/C.Foo2901 {abs_path}/one/two/three/d.foo902 {abs_path}/one/two/three/directory_foo",902 {abs_path}/one/two/three/directory_foo/",903 abs_path = &abs_path904 ),905 );906}
10 unmodified lines
917 {abs_path}/one/b.foo918 {abs_path}/one/two/c.foo919 {abs_path}/one/two/C.Foo2920 {abs_path}/one/two/three/d.foo921 {abs_path}/one/two/three/directory_foo",921 {abs_path}/one/two/three/directory_foo/",922 abs_path = &abs_path923 ),924 );925}
11 unmodified lines
937 {abs_path}/one/b.foo938 {abs_path}/one/two/c.foo939 {abs_path}/one/two/C.Foo2940 {abs_path}/one/two/three/d.foo941 {abs_path}/one/two/three/directory_foo",941 {abs_path}/one/two/three/directory_foo/",942 abs_path = &abs_path943 ),944 );945}
16 unmodified lines
962 te.assert_output(&["--type", "f", "e1"], "./e1 e2");963964 te.assert_output(965 &["--type", "d"],966 "./one967 ./one/two968 ./one/two/three969 ./one/two/three/directory_foo",966 "./one/967 ./one/two/968 ./one/two/three/969 ./one/two/three/directory_foo/",970 );971972 te.assert_output(973 &["--type", "d", "--type", "l"],974 "./one975 ./one/two976 ./one/two/three977 ./one/two/three/directory_foo974 "./one/975 ./one/two/976 ./one/two/three/977 ./one/two/three/directory_foo/978 ./symlink",979 );980981 te.assert_output(&["--type", "l"], "./symlink");
18 unmodified lines
10001001 te.assert_output(1002 &["--type", "executable", "--type", "directory"],1003 "./executable-file.sh1004 ./one1005 ./one/two1006 ./one/two/three1007 ./one/two/three/directory_foo",1004 ./one/1005 ./one/two/1006 ./one/two/three/1007 ./one/two/three/directory_foo/",1008 );1009}10101011/// Test `--type empty`
8 unmodified lines
10201021 te.assert_output(1022 &["--type", "empty"],1023 "./0_bytes.foo1024 ./dir_empty",1024 ./dir_empty/",1025 );10261027 te.assert_output(1028 &["--type", "empty", "--type", "file", "--type", "directory"],1029 "./0_bytes.foo1030 ./dir_empty",1030 ./dir_empty/",1031 );10321033 te.assert_output(&["--type", "empty", "--type", "file"], "./0_bytes.foo");10341035 te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty");1035 te.assert_output(&["--type", "empty", "--type", "directory"], "./dir_empty/");1036}10371038/// File extension (--extension)1039#[test]
62 unmodified lines
11021103 te.assert_output(1104 &["^[^.]+$"],1105 "./aa1106 ./one1106 ./one/1107 ./one/bb1108 ./one/two1109 ./one/two/three1108 ./one/two/1109 ./one/two/three/1110 ./one/two/three/d1111 ./one/two/three/directory_foo1111 ./one/two/three/directory_foo/1112 ./symlink",1113 );11141115 te.assert_output(
31 unmodified lines
1147 &format!(1148 "{dir}/a.foo1149 {dir}/broken_symlink1150 {dir}/e1 e21151 {dir}/one1151 {dir}/one/1152 {dir}/one/b.foo1153 {dir}/one/two1153 {dir}/one/two/1154 {dir}/one/two/c.foo1155 {dir}/one/two/C.Foo21156 {dir}/one/two/three1156 {dir}/one/two/three/1157 {dir}/one/two/three/d.foo1158 {dir}/one/two/three/directory_foo1158 {dir}/one/two/three/directory_foo/1159 {dir}/symlink",1160 dir = &parent_parent1161 ),1162 );
10 unmodified lines
1173 &["--absolute-path"],1174 &format!(1175 "{abs_path}/{expected_path}/c.foo1176 {abs_path}/{expected_path}/C.Foo21177 {abs_path}/{expected_path}/three1177 {abs_path}/{expected_path}/three/1178 {abs_path}/{expected_path}/three/d.foo1179 {abs_path}/{expected_path}/three/directory_foo",1179 {abs_path}/{expected_path}/three/directory_foo/",1180 abs_path = &abs_path,1181 expected_path = expected_path1182 ),1183 );
7 unmodified lines
1191 &["", &format!("{abs_path}/symlink", abs_path = abs_path)],1192 &format!(1193 "{abs_path}/symlink/c.foo1194 {abs_path}/symlink/C.Foo21195 {abs_path}/symlink/three1195 {abs_path}/symlink/three/1196 {abs_path}/symlink/three/d.foo1197 {abs_path}/symlink/three/directory_foo",1197 {abs_path}/symlink/three/directory_foo/",1198 abs_path = &abs_path1199 ),1200 );1201}
13 unmodified lines
1215 "--full-path",1216 &format!("^{prefix}.*three", prefix = prefix),1217 ],1218 &format!(1219 "{abs_path}/{expected_path}/three1219 "{abs_path}/{expected_path}/three/1220 {abs_path}/{expected_path}/three/d.foo1221 {abs_path}/{expected_path}/three/directory_foo",1221 {abs_path}/{expected_path}/three/directory_foo/",1222 abs_path = &abs_path,1223 expected_path = expected_path1224 ),1225 );
10 unmodified lines
1236 &format!("^{prefix}.*symlink.*three", prefix = prefix),1237 &format!("{abs_path}/symlink", abs_path = abs_path),1238 ],1239 &format!(1240 "{abs_path}/symlink/three1240 "{abs_path}/symlink/three/1241 {abs_path}/symlink/three/d.foo1242 {abs_path}/symlink/three/directory_foo",1242 {abs_path}/symlink/three/directory_foo/",1243 abs_path = &abs_path1244 ),1245 );1246}
3 unmodified lines
1250 let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES);12511252 te.assert_output(1253 &["--exclude", "*.foo"],1254 "./one1255 ./one/two1254 "./one/1255 ./one/two/1256 ./one/two/C.Foo21257 ./one/two/three1258 ./one/two/three/directory_foo1257 ./one/two/three/1258 ./one/two/three/directory_foo/1259 ./e1 e21260 ./symlink",1261 );12621263 te.assert_output(1264 &["--exclude", "*.foo", "--exclude", "*.Foo2"],1265 "./one1266 ./one/two1267 ./one/two/three1268 ./one/two/three/directory_foo1265 "./one/1266 ./one/two/1267 ./one/two/three/1268 ./one/two/three/directory_foo/1269 ./e1 e21270 ./symlink",1271 );12721273 te.assert_output(1274 &["--exclude", "*.foo", "--exclude", "*.Foo2", "foo"],1275 "./one/two/three/directory_foo",1275 "./one/two/three/directory_foo/",1276 );12771278 te.assert_output(1279 &["--exclude", "one/two", "foo"],1279 &["--exclude", "one/two/", "foo"],1280 "./a.foo1281 ./one/b.foo",1282 );12831284 te.assert_output(1285 &["--exclude", "one/**/*.foo"],1286 "./a.foo1287 ./e1 e21288 ./one1289 ./one/two1288 ./one/1289 ./one/two/1290 ./one/two/C.Foo21291 ./one/two/three1292 ./one/two/three/directory_foo1291 ./one/two/three/1292 ./one/two/three/directory_foo/1293 ./symlink",1294 );1295}1296
488 unmodified lines
1785 "one=b.foo1786 one=two=c.foo1787 one=two=C.Foo21788 one=two=three=d.foo1789 one=two=three=directory_foo",1789 one=two=three=directory_foo=",1790 );1791}17921793#[test]
2 unmodified lines
17961797 te.assert_output(1798 &["--base-directory", "one"],1799 "./b.foo1800 ./two1800 ./two/1801 ./two/c.foo1802 ./two/C.Foo21803 ./two/three1803 ./two/three/1804 ./two/three/d.foo1805 ./two/three/directory_foo",1805 ./two/three/directory_foo/",1806 );18071808 te.assert_output(1809 &["--base-directory", "one/two", "foo"],1809 &["--base-directory", "one/two/", "foo"],1810 "./c.foo1811 ./C.Foo21812 ./three/d.foo1813 ./three/directory_foo",1813 ./three/directory_foo/",1814 );18151816 // Explicit root path1817 te.assert_output(1818 &["--base-directory", "one", "foo", "two"],1819 "two/c.foo1820 two/C.Foo21821 two/three/d.foo1822 two/three/directory_foo",1822 two/three/directory_foo/",1823 );18241825 // Ignore base directory when absolute path is used1826 let (te, abs_path) = get_test_env_with_abs_path(DEFAULT_DIRS, DEFAULT_FILES);1827 let abs_base_dir = &format!("{abs_path}/one/two", abs_path = &abs_path);1827 let abs_base_dir = &format!("{abs_path}/one/two/", abs_path = &abs_path);1828 te.assert_output(1829 &["--base-directory", abs_base_dir, "foo", &abs_path],1830 &format!(1831 "{abs_path}/a.foo1832 {abs_path}/one/b.foo1833 {abs_path}/one/two/c.foo1834 {abs_path}/one/two/C.Foo21835 {abs_path}/one/two/three/d.foo1836 {abs_path}/one/two/three/directory_foo",1836 {abs_path}/one/two/three/directory_foo/",1837 abs_path = &abs_path1838 ),1839 );1840}
147 unmodified lines
1988 te.assert_output(1989 &["--strip-cwd-prefix", "."],1990 "a.foo1991 e1 e21992 one1992 one/1993 one/b.foo1994 one/two1994 one/two/1995 one/two/c.foo1996 one/two/C.Foo21997 one/two/three1997 one/two/three/1998 one/two/three/d.foo1999 one/two/three/directory_foo1999 one/two/three/directory_foo/2000 symlink",2001 );2002}