Skip to content

Commit

Permalink
Always dereference symbolic links when copying files in ct
Browse files Browse the repository at this point in the history
I found that the patch [1] I did for dereferencing symbolic link in
common tests not always works. The `copy_bare_suites` function only
runs when the ct suite is placed in the root folder, but it doesn't run
when it is placed in the `test/` folder.

In this commit, I added `copy_bare_suites` to all the cases of
`maybe_inject_test_dir`. I also avoided copying the folder again
in `rebar_prv_compile` when it is a test directory. This last extra
copy was run just after the steps in `rebar_prv_common_test` so it was
rewriting everything done in `copy_bare_suites`, leaving the folder with
the broken symbolic links.

[1] erlang#2731
  • Loading branch information
gonzalobf committed Aug 25, 2022
1 parent c0c5a0e commit 0970fd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/rebar/src/rebar_prv_common_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ maybe_inject_test_dir(State, AppAcc, [App|Rest], Dir) ->
Opts = inject_test_dir(rebar_state:opts(State), rebar_app_info:out_dir(App)),
{rebar_state:opts(State, Opts), AppAcc ++ [App]};
{ok, Path} ->
To = filename:join([rebar_app_info:out_dir(App), Path]),
ok = copy_bare_suites(Dir, To),
Opts = inject_test_dir(rebar_app_info:opts(App), Path),
{State, AppAcc ++ [rebar_app_info:opts(App, Opts)] ++ Rest};
{error, badparent} ->
Expand All @@ -609,6 +611,8 @@ maybe_inject_test_dir(State, AppAcc, [], Dir) ->
Opts = inject_test_dir(rebar_state:opts(State), ExtrasDir),
{rebar_state:opts(State, Opts), AppAcc};
{ok, Path} ->
To = filename:join([rebar_dir:base_dir(State), Path]),
ok = copy_bare_suites(Dir, To),
Opts = inject_test_dir(rebar_state:opts(State), Path),
{rebar_state:opts(State, Opts), AppAcc};
{error, badparent} ->
Expand Down
3 changes: 3 additions & 0 deletions apps/rebar/src/rebar_prv_compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ symlink_or_copy_existing(OldAppDir, AppDir, Dir) ->
false -> ok
end.

copy(_, _, "test") ->
% In the case of the test directory, the files are copied by rebar_prv_common_test
ok;
copy(OldAppDir, AppDir, Dir) ->
Source = filename:join([OldAppDir, Dir]),
Target = filename:join([AppDir, Dir]),
Expand Down

0 comments on commit 0970fd2

Please sign in to comment.