aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorJosé Valim <[email protected]>2012-02-20 14:45:43 +0100
committerBjörn Gustavsson <[email protected]>2012-09-17 12:00:17 +0200
commit67b0f0c042fe833a666fa2f6d9b882a1c66998db (patch)
treed2b33c11487d75139eb651debf9121251dc180b5 /lib/stdlib/test
parentb58ce62a0cf296ca8cd8cd77b053bc70ecf28758 (diff)
downloadotp-67b0f0c042fe833a666fa2f6d9b882a1c66998db.tar.gz
otp-67b0f0c042fe833a666fa2f6d9b882a1c66998db.tar.bz2
otp-67b0f0c042fe833a666fa2f6d9b882a1c66998db.zip
Allow ** in filelib:wildcard
Two adjacent * used as a single pattern will match all files and zero or more directories and subdirectories.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/filelib_SUITE.erl47
1 files changed, 46 insertions, 1 deletions
diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl
index 94da355f36..1fd7518519 100644
--- a/lib/stdlib/test/filelib_SUITE.erl
+++ b/lib/stdlib/test/filelib_SUITE.erl
@@ -188,7 +188,52 @@ do_wildcard_6(Dir, Wcf) ->
["xbin"] = Wcf("*"),
All = Wcf("*/*"),
del(Files),
- ok = file:del_dir(filename:join(Dir, "xbin")).
+ ok = file:del_dir(filename:join(Dir, "xbin")),
+ do_wildcard_7(Dir, Wcf).
+
+do_wildcard_7(Dir, Wcf) ->
+ Dirs = ["blurf","xa","yyy"],
+ SubDirs = ["blurf/nisse"],
+ foreach(fun(D) ->
+ ok = file:make_dir(filename:join(Dir, D))
+ end, Dirs ++ SubDirs),
+ All = ["blurf/nisse/baz","xa/arne","xa/kalle","yyy/arne"],
+ Files = mkfiles(lists:reverse(All), Dir),
+
+ %% Test.
+ Listing = Wcf("**"),
+ ["blurf","blurf/nisse","blurf/nisse/baz",
+ "xa","xa/arne","xa/kalle","yyy","yyy/arne"] = Listing,
+ Listing = Wcf("**/*"),
+ ["xa/arne","yyy/arne"] = Wcf("**/arne"),
+ ["blurf/nisse"] = Wcf("**/nisse"),
+ [] = Wcf("mountain/**"),
+
+ %% Cleanup
+ del(Files),
+ foreach(fun(D) ->
+ ok = file:del_dir(filename:join(Dir, D))
+ end, SubDirs ++ Dirs),
+ do_wildcard_8(Dir, Wcf).
+
+do_wildcard_8(Dir, Wcf) ->
+ Dirs0 = ["blurf"],
+ Dirs1 = ["blurf/nisse"],
+ Dirs2 = ["blurf/nisse/a", "blurf/nisse/b"],
+ foreach(fun(D) ->
+ ok = file:make_dir(filename:join(Dir, D))
+ end, Dirs0 ++ Dirs1 ++ Dirs2),
+ All = ["blurf/nisse/a/1.txt", "blurf/nisse/b/2.txt", "blurf/nisse/b/3.txt"],
+ Files = mkfiles(lists:reverse(All), Dir),
+
+ %% Test.
+ All = Wcf("**/blurf/**/*.txt"),
+
+ %% Cleanup
+ del(Files),
+ foreach(fun(D) ->
+ ok = file:del_dir(filename:join(Dir, D))
+ end, Dirs2 ++ Dirs1 ++ Dirs0).
fold_files(Config) when is_list(Config) ->
?line Dir = filename:join(?config(priv_dir, Config), "fold_files"),