Skip to content

Commit

Permalink
Fix deps path check in rebar_ct:collect_glob/3
Browse files Browse the repository at this point in the history
Since rebar_deps:get_deps_dir/1 returns an absolute path,
lists:member(Deps, Parts2) will always return false, thus .test.spec
files in deps/ will not be ignored.
  • Loading branch information
stwind committed Dec 11, 2014
1 parent 01ef314 commit a83c80d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@ Drew Varner
Roberto Aloi
Luis Rascao
Vlad Dumitrescu
stwind
8 changes: 7 additions & 1 deletion inttest/ct2/ct2_rt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ files() ->
[{create, "ebin/foo.app", app(foo)},
{copy, "../../rebar", "rebar"},
{copy, "foo.test.spec", "foo.test.spec"},
{copy, "deps/bar.test.spec", "deps/bar.test.spec"},
{copy, "foo_SUITE.erl", "test/foo_SUITE.erl"}].

run(_Dir) ->
{ok, _} = retest:sh("./rebar compile ct -vvv"),
Ref = retest:sh("./rebar compile ct -vvv", [async]),
{ok, [[CTRunCmd]]} = retest:sh_expect(Ref, "^\"ct_run.*",
[global, {capture, first, binary}]),
{match, _} = re:run(CTRunCmd, "foo.test.spec", [global]),
%% deps/bar.test.spec should be ignored by rebar_ct:collect_glob/3
nomatch = re:run(CTRunCmd, "bar.test.spec", [global]),
ok.

%%
Expand Down
1 change: 1 addition & 0 deletions inttest/ct2/deps/bar.test.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%% this test spec should be ignored
3 changes: 2 additions & 1 deletion src/rebar_ct.erl
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,14 @@ get_cover_config(Config, Cwd) ->

collect_glob(Config, Cwd, Glob) ->
{true, Deps} = rebar_deps:get_deps_dir(Config),
DepsDir = filename:basename(Deps),
CwdParts = filename:split(Cwd),
filelib:fold_files(Cwd, Glob, true, fun(F, Acc) ->
%% Ignore any specs under the deps/ directory. Do this pulling
%% the dirname off the F and then splitting it into a list.
Parts = filename:split(filename:dirname(F)),
Parts2 = remove_common_prefix(Parts, CwdParts),
case lists:member(Deps, Parts2) of
case lists:member(DepsDir, Parts2) of
true ->
Acc; % There is a directory named "deps" in path
false ->
Expand Down

0 comments on commit a83c80d

Please sign in to comment.