|
|
@ -11,8 +11,8 @@ |
|
|
|
reset_nonexistent_dir/1, |
|
|
|
reset_empty_dir/1, |
|
|
|
reset_dir/1, |
|
|
|
relative_path/1, |
|
|
|
reduce_path/1]). |
|
|
|
path_from_ancestor/1, |
|
|
|
canonical_path/1]). |
|
|
|
|
|
|
|
-include_lib("common_test/include/ct.hrl"). |
|
|
|
-include_lib("eunit/include/eunit.hrl"). |
|
|
@ -22,7 +22,7 @@ |
|
|
|
all() -> |
|
|
|
[{group, tmpdir}, |
|
|
|
{group, reset_dir}, |
|
|
|
relative_path, reduce_path]. |
|
|
|
path_from_ancestor, canonical_path]. |
|
|
|
|
|
|
|
groups() -> |
|
|
|
[{tmpdir, [], [raw_tmpdir, empty_tmpdir, simple_tmpdir, multi_tmpdir]}, |
|
|
@ -88,19 +88,19 @@ reset_dir(Config) -> |
|
|
|
?assert(filelib:is_dir(TmpDir)), |
|
|
|
{ok, []} = file:list_dir(TmpDir). |
|
|
|
|
|
|
|
relative_path(_Config) -> |
|
|
|
?assertEqual({ok, "foo/bar/baz"}, rebar_file_utils:relative_path("/foo/bar/baz", "/")), |
|
|
|
?assertEqual({ok, "bar/baz"}, rebar_file_utils:relative_path("/foo/bar/baz", "/foo")), |
|
|
|
?assertEqual({ok, "bar"}, rebar_file_utils:relative_path("foo/bar", "foo")), |
|
|
|
?assertEqual({ok, "bar"}, rebar_file_utils:relative_path("foo/bar/", "foo/")), |
|
|
|
?assertEqual({error, not_relative}, rebar_file_utils:relative_path("/foo/bar/baz", "/qux")), |
|
|
|
?assertEqual({error, not_relative}, rebar_file_utils:relative_path("/foo/bar/baz", "/foo/bar/baz/qux")). |
|
|
|
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")). |
|
|
|
|
|
|
|
reduce_path(_Config) -> |
|
|
|
?assertEqual("/", rebar_file_utils:reduce_path("/")), |
|
|
|
?assertEqual("/", rebar_file_utils:reduce_path("/../../..")), |
|
|
|
?assertEqual("/foo", rebar_file_utils:reduce_path("/foo/bar/..")), |
|
|
|
?assertEqual("/foo", rebar_file_utils:reduce_path("/foo/../foo")), |
|
|
|
?assertEqual("/foo", rebar_file_utils:reduce_path("/foo/.")), |
|
|
|
?assertEqual("/foo", rebar_file_utils:reduce_path("/foo/./.")), |
|
|
|
?assertEqual("/foo/bar", rebar_file_utils:reduce_path("/foo/./bar")). |
|
|
|
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")). |