diff options
Diffstat (limited to 'test/rebar_file_utils_SUITE.erl')
-rw-r--r-- | test/rebar_file_utils_SUITE.erl | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/rebar_file_utils_SUITE.erl b/test/rebar_file_utils_SUITE.erl index 03a2d54..0f444d5 100644 --- a/test/rebar_file_utils_SUITE.erl +++ b/test/rebar_file_utils_SUITE.erl @@ -10,7 +10,9 @@ multi_tmpdir/1, reset_nonexistent_dir/1, reset_empty_dir/1, - reset_dir/1]). + reset_dir/1, + path_from_ancestor/1, + canonical_path/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -19,7 +21,8 @@ all() -> [{group, tmpdir}, - {group, reset_dir}]. + {group, reset_dir}, + path_from_ancestor, canonical_path]. groups() -> [{tmpdir, [], [raw_tmpdir, empty_tmpdir, simple_tmpdir, multi_tmpdir]}, @@ -84,3 +87,20 @@ reset_dir(Config) -> ok = rebar_file_utils:reset_dir(TmpDir), ?assert(filelib:is_dir(TmpDir)), {ok, []} = file:list_dir(TmpDir). + +path_from_ancestor(_Config) -> + ?assertEqual({ok, "foo/bar/baz"}, rebar_file_utils:path_from_ancestor("/foo/bar/baz", "/")), + ?assertEqual({ok, "bar/baz"}, rebar_file_utils:path_from_ancestor("/foo/bar/baz", "/foo")), + ?assertEqual({ok, "bar"}, rebar_file_utils:path_from_ancestor("foo/bar", "foo")), + ?assertEqual({ok, "bar"}, rebar_file_utils:path_from_ancestor("foo/bar/", "foo/")), + ?assertEqual({error, badparent}, rebar_file_utils:path_from_ancestor("/foo/bar/baz", "/qux")), + ?assertEqual({error, badparent}, rebar_file_utils:path_from_ancestor("/foo/bar/baz", "/foo/bar/baz/qux")). + +canonical_path(_Config) -> + ?assertEqual("/", rebar_file_utils:canonical_path("/")), + ?assertEqual("/", rebar_file_utils:canonical_path("/../../..")), + ?assertEqual("/foo", rebar_file_utils:canonical_path("/foo/bar/..")), + ?assertEqual("/foo", rebar_file_utils:canonical_path("/foo/../foo")), + ?assertEqual("/foo", rebar_file_utils:canonical_path("/foo/.")), + ?assertEqual("/foo", rebar_file_utils:canonical_path("/foo/./.")), + ?assertEqual("/foo/bar", rebar_file_utils:canonical_path("/foo/./bar")).
\ No newline at end of file |