Fix whitespace errors

This commit is contained in:
Tuncer Ayaz 2015-04-02 16:10:31 +02:00
parent 65b0f917b8
commit 6127f528b9
5 changed files with 36 additions and 28 deletions

View file

@ -47,25 +47,25 @@ ifdef_test() ->
{ok, Output} = retest:sh("./rebar -v eunit"), {ok, Output} = retest:sh("./rebar -v eunit"),
io:format("output => ~p~n", [Output]), io:format("output => ~p~n", [Output]),
?assert(check_output(Output, "foo")), ?assert(check_output(Output, "foo")),
{ok,Listing} = file:list_dir(".eunit"), {ok, Listing} = file:list_dir(".eunit"),
?assert(check_output(Listing, "foo.beam")), ?assert(check_output(Listing, "foo.beam")),
?assertMatch({ok,_}, retest:sh("./rebar clean")). ?assertMatch({ok,_}, retest:sh("./rebar clean")).
cover_export_json_test() -> cover_export_json_test() ->
{ok,Output} = {ok, Output} =
retest:sh("./rebar -v -C rebar-cover_export_json.config eunit"), retest:sh("./rebar -v -C rebar-cover_export_json.config eunit"),
?assert(check_output(Output, "foo")), ?assert(check_output(Output, "foo")),
?assertEqual( ?assertEqual(
{ok, <<"{\"module\":\"foo\",\"covered\":2,\"not_covered\":1}">>}, {ok, <<"{\"module\":\"foo\",\"covered\":2,\"not_covered\":1}">>},
file:read_file(".eunit/foo.COVER.json")), file:read_file(".eunit/foo.COVER.json")),
?assertMatch( ?assertMatch(
{ok,_}, {ok, _},
retest:sh("./rebar -C rebar-cover_export_json.config clean")). retest:sh("./rebar -C rebar-cover_export_json.config clean")).
check_output(Output,Target) -> check_output(Output,Target) ->
lists:any(fun(Line) -> lists:any(fun(Line) ->
string:str(Line, Target) > 0 string:str(Line, Target) > 0
end, Output). end, Output).
app(Name) -> app(Name) ->
App = {application, Name, App = {application, Name,
[{description, atom_to_list(Name)}, [{description, atom_to_list(Name)},

View file

@ -54,7 +54,7 @@ close(F) ->
ok = file:close(F). ok = file:close(F).
exit() -> exit() ->
cover:stop(). cover:stop().
init(false, _BeamFiles, _TargetDir) -> init(false, _BeamFiles, _TargetDir) ->
{ok, not_enabled}; {ok, not_enabled};
@ -260,7 +260,7 @@ export_json_coverage(TargetDir,Coverage) ->
end, Coverage). end, Coverage).
export_json_coverage_to_file(TargetDir, {Module, Covered, NotCovered}) -> export_json_coverage_to_file(TargetDir, {Module, Covered, NotCovered}) ->
{ok,JsonFile} = file:open(json_file(TargetDir, Module), [write]), {ok, JsonFile} = file:open(json_file(TargetDir, Module), [write]),
io:format(JsonFile, io:format(JsonFile,
"{\"module\":~p,\"covered\":~p,\"not_covered\":~p}", "{\"module\":~p,\"covered\":~p,\"not_covered\":~p}",
[atom_to_list(Module), Covered, NotCovered]), [atom_to_list(Module), Covered, NotCovered]),

View file

@ -295,18 +295,23 @@ 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), DepsDir = filename:basename(Deps),
CwdParts = filename:split(Cwd), CwdParts = filename:split(Cwd),
filelib:fold_files(Cwd, Glob, true, fun(F, Acc) -> filelib:fold_files(
%% Ignore any specs under the deps/ directory. Do this pulling Cwd,
%% the dirname off the F and then splitting it into a list. Glob,
Parts = filename:split(filename:dirname(F)), true,
Parts2 = remove_common_prefix(Parts, CwdParts), fun(F, Acc) ->
case lists:member(DepsDir, Parts2) of %% Ignore any specs under the deps/ directory. Do this pulling
true -> %% the dirname off the F and then splitting it into a list.
Acc; % There is a directory named "deps" in path Parts = filename:split(filename:dirname(F)),
false -> Parts2 = remove_common_prefix(Parts, CwdParts),
[F | Acc] % No "deps" directory in path case lists:member(DepsDir, Parts2) of
end true ->
end, []). %% There is a directory named "deps" in path
Acc;
false ->
[F | Acc] % No "deps" directory in path
end
end, []).
remove_common_prefix([H1|T1], [H1|T2]) -> remove_common_prefix([H1|T1], [H1|T2]) ->
remove_common_prefix(T1, T2); remove_common_prefix(T1, T2);

View file

@ -74,11 +74,12 @@ preprocess(SourceFile, TargetFile, _Config) ->
%% http://erlang.org/doc/man/appup.html. %% http://erlang.org/doc/man/appup.html.
{ok, [{_Vsn, UpFromVsn, DownToVsn} = AppUp]} {ok, [{_Vsn, UpFromVsn, DownToVsn} = AppUp]}
when is_list(UpFromVsn), is_list(DownToVsn) -> when is_list(UpFromVsn), is_list(DownToVsn) ->
case file:write_file(TargetFile, case file:write_file(
lists:flatten(io_lib:format("~p.", [AppUp]))) of TargetFile,
lists:flatten(io_lib:format("~p.", [AppUp]))) of
{error, Reason} -> {error, Reason} ->
?ABORT("Failed writing to target file ~s due to ~s", ?ABORT("Failed writing to target file ~s due to ~s",
[TargetFile, Reason]); [TargetFile, Reason]);
ok -> ok ok -> ok
end; end;
{error, Reason} -> {error, Reason} ->

View file

@ -196,7 +196,8 @@ process_overlay(Config, ReltoolConfig) ->
%% providing an additional file on the command-line. %% providing an additional file on the command-line.
%% %%
overlay_vars(Config, Vars0, ReltoolConfig) -> overlay_vars(Config, Vars0, ReltoolConfig) ->
BaseVars = load_vars_file([proplists:get_value(overlay_vars, ReltoolConfig)]), BaseVars = load_vars_file(
[proplists:get_value(overlay_vars, ReltoolConfig)]),
OverlayVars = rebar_config:get_global(Config, overlay_vars, []), OverlayVars = rebar_config:get_global(Config, overlay_vars, []),
OverrideVars = load_vars_file(string:tokens(OverlayVars, ",")), OverrideVars = load_vars_file(string:tokens(OverlayVars, ",")),
M = fun merge_overlay_var/3, M = fun merge_overlay_var/3,
@ -327,7 +328,8 @@ overlay_files(ReltoolConfig) ->
{overlay, Overlay} when is_list(Overlay) -> {overlay, Overlay} when is_list(Overlay) ->
Overlay; Overlay;
false -> false ->
?INFO("No {overlay, [...]} found in reltool.config.\n", []), ?INFO("No {overlay, [...]} found in reltool.config.\n",
[]),
[]; [];
_ -> _ ->
?ABORT("{overlay, [...]} entry in reltool.config " ?ABORT("{overlay, [...]} entry in reltool.config "