From da0e2c22959c976420b60def760b348aa200d6e2 Mon Sep 17 00:00:00 2001 From: Garrett Smith Date: Mon, 2 May 2016 16:03:01 -0500 Subject: 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. --- test/rebar_file_utils_SUITE.erl | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'test') 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")). -- cgit v1.1 From 37abeb40c08813e88a095d3d684f23e3d6c2ee8f Mon Sep 17 00:00:00 2001 From: Garrett Smith Date: Mon, 2 May 2016 19:07:51 -0700 Subject: Reinstated test --- test/rebar_file_utils_SUITE.erl | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/rebar_file_utils_SUITE.erl b/test/rebar_file_utils_SUITE.erl index 23c5792..a44a06d 100644 --- a/test/rebar_file_utils_SUITE.erl +++ b/test/rebar_file_utils_SUITE.erl @@ -24,6 +24,7 @@ all() -> [{group, tmpdir}, {group, reset_dir}, + path_from_ancestor, canonical_path, resolve_link, split_dirname]. -- cgit v1.1