Merge pull request #406 from stwind/master

Fix deps path check in rebar_ct:collect_glob/3
This commit is contained in:
Fred Hebert 2014-12-21 15:02:39 -05:00
commit 6584defdda
4 changed files with 11 additions and 2 deletions

1
THANKS
View file

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

View file

@ -9,10 +9,16 @@ files() ->
[{create, "ebin/foo.app", app(foo)}, [{create, "ebin/foo.app", app(foo)},
{copy, "../../rebar", "rebar"}, {copy, "../../rebar", "rebar"},
{copy, "foo.test.spec", "foo.test.spec"}, {copy, "foo.test.spec", "foo.test.spec"},
{copy, "deps/bar.test.spec", "deps/bar.test.spec"},
{copy, "foo_SUITE.erl", "test/foo_SUITE.erl"}]. {copy, "foo_SUITE.erl", "test/foo_SUITE.erl"}].
run(_Dir) -> 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. 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) -> collect_glob(Config, Cwd, Glob) ->
{true, Deps} = rebar_deps:get_deps_dir(Config), {true, Deps} = rebar_deps:get_deps_dir(Config),
DepsDir = filename:basename(Deps),
CwdParts = filename:split(Cwd), CwdParts = filename:split(Cwd),
filelib:fold_files(Cwd, Glob, true, fun(F, Acc) -> filelib:fold_files(Cwd, Glob, true, fun(F, Acc) ->
%% Ignore any specs under the deps/ directory. Do this pulling %% Ignore any specs under the deps/ directory. Do this pulling
%% the dirname off the F and then splitting it into a list. %% the dirname off the F and then splitting it into a list.
Parts = filename:split(filename:dirname(F)), Parts = filename:split(filename:dirname(F)),
Parts2 = remove_common_prefix(Parts, CwdParts), Parts2 = remove_common_prefix(Parts, CwdParts),
case lists:member(Deps, Parts2) of case lists:member(DepsDir, Parts2) of
true -> true ->
Acc; % There is a directory named "deps" in path Acc; % There is a directory named "deps" in path
false -> false ->