summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGarrett Smith <g@rre.tt>2016-05-02 16:03:01 -0500
committerGarrett Smith <g@rre.tt>2016-05-02 16:03:01 -0500
commitda0e2c22959c976420b60def760b348aa200d6e2 (patch)
treef3d2952e2485d2820c0a735724bc893d8da95fab /test
parentc9cc58d2b885249da3ad7f738f922a83bfb302d1 (diff)
Option to format compiler sources
By default rebar3 displays compiler sources as absolute paths in their original location, which is under the build dir. This change introduces an option 'compiler_source_format' to format sources in two alternative ways: relative absolute When either 'relative' or 'absolute' are specified, the file is resolved to its original location when it is a link. When 'relative' is specified, the path is displayed relative to the current working directory. When 'absolute' is specified, the path is absolute. The default value is 'unchaged' which leaves the compiler source unchanged. This is arguably too flexible as I suspect most people would opt for 'relative' all the time - it's the most compact representation of the file and is sufficient to find the source given cwd. The change however is meant to introduce the change gradually, preserving existing behavior and giving users a choice for formats. In time perhaps the default can be changed to 'relative' - but still allowing users to revert to the other two options ('absolutel' and 'unchanged') as needed.
Diffstat (limited to 'test')
-rw-r--r--test/rebar_file_utils_SUITE.erl27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/rebar_file_utils_SUITE.erl b/test/rebar_file_utils_SUITE.erl
index c1f85b3..23c5792 100644
--- a/test/rebar_file_utils_SUITE.erl
+++ b/test/rebar_file_utils_SUITE.erl
@@ -12,7 +12,9 @@
reset_empty_dir/1,
reset_dir/1,
path_from_ancestor/1,
- canonical_path/1]).
+ canonical_path/1,
+ resolve_link/1,
+ split_dirname/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -22,7 +24,9 @@
all() ->
[{group, tmpdir},
{group, reset_dir},
- path_from_ancestor, canonical_path].
+ canonical_path,
+ resolve_link,
+ split_dirname].
groups() ->
[{tmpdir, [], [raw_tmpdir, empty_tmpdir, simple_tmpdir, multi_tmpdir]},
@@ -111,3 +115,22 @@ canonical_path(_Config) ->
?assertEqual(Root ++ "foo", rebar_file_utils:canonical_path("/foo/./.")),
?assertEqual(filename:nativename(Root ++ "foo/bar"),
rebar_file_utils:canonical_path("/foo/./bar")).
+
+resolve_link(_Config) ->
+ TmpDir = rebar_file_utils:system_tmpdir(
+ ["rebar_file_utils_SUITE", "resolve_link"]),
+ Link = filename:join(TmpDir, "link"),
+ Target = filename:join(TmpDir, "link-target"),
+ ec_file:remove(TmpDir, [recursive]),
+ ok = filelib:ensure_dir(Target),
+ ok = file:write_file(Target, <<>>),
+ ok = file:make_symlink(Target, Link),
+ ?assertEqual(Target, rebar_file_utils:resolve_link(Link)).
+
+split_dirname(_Config) ->
+ ?assertEqual({".", ""}, rebar_file_utils:split_dirname("")),
+ ?assertEqual({"/", ""}, rebar_file_utils:split_dirname("/")),
+ ?assertEqual({"/", "foo"}, rebar_file_utils:split_dirname("/foo")),
+ ?assertEqual({".", "foo"}, rebar_file_utils:split_dirname("foo")),
+ ?assertEqual({"/foo", "bar"}, rebar_file_utils:split_dirname("/foo/bar")),
+ ?assertEqual({"foo", "bar"}, rebar_file_utils:split_dirname("foo/bar")).