diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-09-25 17:46:03 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-09-25 17:46:03 -0400 |
commit | 509c7afec67a980e73efb61c53efd87a53e7e14e (patch) | |
tree | 0fdf2991408531cb475ea05cddc17d90632c9b39 /test/rebar_file_utils_SUITE.erl | |
parent | 4d76a556e20665e0d3f77910635586613036fa4e (diff) | |
parent | ae275c6396545defc80a765a6b835d01f4c76599 (diff) |
Merge pull request #800 from talentdeficit/extract_path_utils
extract `retarget_path/2', `relative_path/2' and `reduce_path/1' and add tests
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 |