Skip to content

Commit

Permalink
Fix tests without resorting to elvis in rebar.config
Browse files Browse the repository at this point in the history
(this way we use the default we've defined internally)
  • Loading branch information
paulo-ferraz-oliveira committed Sep 19, 2021
1 parent 140be03 commit 12a1c35
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions elvis.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[].
2 changes: 1 addition & 1 deletion src/rebar3_lint.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ init(State) ->
-spec main([]) -> ok | {fail, [elvis_result:file()]}.
main([]) ->
ok = application:load(elvis_core),
elvis_core:rock(elvis_config:from_rebar("rebar.config")).
elvis_core:rock(rebar3_lint_prv:default_config()).
6 changes: 4 additions & 2 deletions src/rebar3_lint_prv.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-module('rebar3_lint_prv').

-export([init/1, do/1, format_error/1]).
-export([default_config/0]).

-ignore_xref([do/1]).
-ignore_xref([format_error/1]).
Expand Down Expand Up @@ -80,7 +81,9 @@ try_elvis_config_file(State) ->
Filename = filename:join(rebar_dir:root_dir(State), "elvis.config"),
rebar_api:debug("Looking for Elvis in ~s", [Filename]),
try elvis_config:from_file(Filename) of
[] -> default_config();
[] ->
rebar_api:debug("Using default Elvis configuration", []),
default_config();
Config -> Config
catch
throw:Error ->
Expand All @@ -90,7 +93,6 @@ try_elvis_config_file(State) ->

-spec default_config() -> elvis_config:configs().
default_config() ->
rebar_api:debug("Using default Elvis configuration", []),
[#{ dirs => ["apps/*/src/**", "src/**"],
filter => "*.erl",
ruleset => erl_files },
Expand Down
10 changes: 9 additions & 1 deletion test/test_app_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
-module(test_app_SUITE).

-export([all/0, test_app/1]).
-export([init_per_suite/1, end_per_suite/1, all/0, test_app/1]).

-if(?OTP_RELEASE >= 23).
-behaviour(ct_suite).
-endif.

init_per_suite(Config) ->
RebarState = rebar_state:new(),
rebar_state:set(RebarState, elvis, rebar3_lint_prv:default_config()),
Config.

end_per_suite(Config) ->
Config.

all() ->
[test_app].

Expand Down

0 comments on commit 12a1c35

Please sign in to comment.