Fix deps path check in rebar_ct:collect_glob/3

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.
This commit is contained in:
stwind 2014-12-07 16:12:06 +08:00
parent 01ef314951
commit a83c80d4c0
4 changed files with 11 additions and 2 deletions

1
THANKS
View file

@ -130,3 +130,4 @@ Drew Varner
Roberto Aloi
Luis Rascao
Vlad Dumitrescu
stwind

View file

@ -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.
%%

View file

@ -0,0 +1 @@
%% this test spec should be ignored

View file

@ -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 ->