Skip to content

Commit

Permalink
Merge branch 'feature_long_src_paths' of https://github.com/danikp/re…
Browse files Browse the repository at this point in the history
…bar3 into danikp-feature_long_src_paths
  • Loading branch information
ferd committed Apr 27, 2018
2 parents d3efb47 + c22fde1 commit 81bd21b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/rebar_file_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ cp_r(Sources, Dest) ->
{unix, _} ->
EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources],
SourceStr = rebar_string:join(EscSources, " "),
% ensure destination exists before copying files into it
{ok, []} = rebar_utils:sh(?FMT("mkdir -p ~ts",
[rebar_utils:escape_chars(Dest)]),
[{use_stdout, false}, abort_on_error]),
{ok, []} = rebar_utils:sh(?FMT("cp -Rp ~ts \"~ts\"",
[SourceStr, rebar_utils:escape_double_quotes(Dest)]),
[{use_stdout, false}, abort_on_error]),
Expand Down
24 changes: 22 additions & 2 deletions test/rebar_dir_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-export([all/0, init_per_testcase/2, end_per_testcase/2]).

-export([default_src_dirs/1, default_extra_src_dirs/1, default_all_src_dirs/1]).
-export([src_dirs/1, src_dirs_with_opts/1, extra_src_dirs/1, all_src_dirs/1]).
-export([src_dirs/1, alt_src_dir_nested/1, src_dirs_with_opts/1, extra_src_dirs/1, all_src_dirs/1]).
-export([src_dir_opts/1, recursive/1]).
-export([top_src_dirs/1]).
-export([profile_src_dirs/1, profile_extra_src_dirs/1, profile_all_src_dirs/1]).
Expand All @@ -17,7 +17,7 @@


all() -> [default_src_dirs, default_extra_src_dirs, default_all_src_dirs,
src_dirs, extra_src_dirs, all_src_dirs, src_dir_opts, recursive,
src_dirs, alt_src_dir_nested, extra_src_dirs, all_src_dirs, src_dir_opts, recursive,
profile_src_dirs, profile_extra_src_dirs, profile_all_src_dirs,
profile_src_dir_opts, top_src_dirs,
retarget_path, alt_base_dir_abs, alt_base_dir_rel, global_cache_dir,
Expand Down Expand Up @@ -75,6 +75,26 @@ src_dirs(Config) ->

[".", "..", "../..", "bar", "baz", "foo"] = rebar_dir:src_dirs(rebar_state:opts(State)).

alt_src_dir_nested(Config) ->
RebarConfig = [{src_dirs, ["src", "alt/nested"]}],
AppsDir = ?config(apps, Config),
Name1 = ?config(app_one, Config),
Name2 = ?config(app_two, Config),
ModDir = filename:join([AppsDir, "apps", Name1, "alt", "nested"]),
ModDir2 = filename:join([AppsDir, "apps", Name2, "alt", "nested"]),
Mod = "-module(altmod). -export([main/0]). main() -> ok.",

ec_file:mkdir_path(ModDir),
ec_file:mkdir_path(ModDir2),
ok = file:write_file(filename:join([ModDir, "altmod.erl"]), Mod),

Ebin = filename:join([AppsDir, "_build", "default", "lib", Name1, "ebin", "altmod.beam"]),
{ok, State} = rebar_test_utils:run_and_check(
Config, RebarConfig, ["compile"],
{ok, [{file, Ebin}]}
),
["alt/nested", "src"] = rebar_dir:src_dirs(rebar_state:opts(State)).

src_dirs_with_opts(Config) ->
RebarConfig = [{erl_opts, [{src_dirs, ["foo", "bar", "baz"]},
{src_dirs, [{"foo",[{recursive,false}]}, "qux"]}]}],
Expand Down

0 comments on commit 81bd21b

Please sign in to comment.