forked from lambdaclass/erlang-katana
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from inaka/elbrujohalcon.89.create_ktn_meta_suite
Create ktn_meta_SUITE
- Loading branch information
Showing
11 changed files
with
257 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
%%% @doc Meta Testing SUITE | ||
%%% Use with mixer or by yourself. Just include a call to each of its functions | ||
%%% in your common test suites. | ||
%%% Make sure to add an application property to your common test configuration. | ||
-module(ktn_meta_SUITE). | ||
-author('elbrujohalcon@inaka.net'). | ||
|
||
-export([all/0]). | ||
-export([xref/1, dialyzer/1, elvis/1]). | ||
|
||
-type config() :: [{atom(), term()}]. | ||
|
||
-spec all() -> [dialyzer | elvis | xref]. | ||
all() -> [dialyzer, elvis, xref]. | ||
|
||
%% @doc xref's your code using xref_runner | ||
-spec xref(config()) -> {comment, []}. | ||
xref(Config) -> | ||
BaseDir = base_dir(Config), | ||
Dirs = [ filename:join(BaseDir, "ebin") | ||
, filename:join(BaseDir, "test") | ||
], | ||
|
||
ct:comment("Undefined Function Calls"), | ||
UFCs = xref_runner:check(undefined_function_calls, #{dirs => Dirs}), | ||
|
||
ct:comment("Undefined Functions"), | ||
UFs = xref_runner:check(undefined_functions, #{dirs => Dirs}), | ||
|
||
ct:comment("Locals not Used"), | ||
LNUs = xref_runner:check(locals_not_used, #{dirs => Dirs}), | ||
|
||
ct:comment("Deprecated Function Calls"), | ||
DFCs = xref_runner:check(deprecated_function_calls, #{dirs => Dirs}), | ||
|
||
ct:comment("Deprecated Functions"), | ||
DFs = xref_runner:check(deprecated_functions, #{dirs => Dirs}), | ||
|
||
ct:comment("There are no Warnings"), | ||
[] = UFCs ++ UFs ++ LNUs ++ DFCs ++ DFs, | ||
|
||
{comment, ""}. | ||
|
||
%% @doc dialyzes your code. | ||
%% By default it uses all the plts in the project root folder. | ||
%% You can change that by providing a 'plts' parameter in Config. | ||
%% You can also change the warnings using the 'dialyzer_warnings' parameter | ||
-spec dialyzer(config()) -> {comment, []}. | ||
dialyzer(Config) -> | ||
BaseDir = base_dir(Config), | ||
Plts = plts(Config), | ||
Dirs = [ filename:join(BaseDir, "ebin") | ||
, filename:join(BaseDir, "test") | ||
], | ||
Warnings = | ||
case test_server:lookup_config(dialyzer_warnings, Config) of | ||
undefined -> [error_handling, race_conditions, unmatched_returns]; | ||
Ws -> Ws | ||
end, | ||
|
||
ct:comment("Dialyzer must emit no warnings"), | ||
Opts = | ||
[ {analysis_type, succ_typings} | ||
, {plts, Plts} | ||
, {files_rec, Dirs} | ||
, {check_plt, true} | ||
, {warnings, Warnings} | ||
, {get_warnings, true} | ||
], | ||
[] = [dialyzer:format_warning(W, basename) || W <- dialyzer:run(Opts)], | ||
{comment, ""}. | ||
|
||
%% @doc Checks your code with elvis | ||
-spec elvis(config()) -> {comment, []}. | ||
elvis(Config) -> | ||
ElvisConfig = | ||
case test_server:lookup_config(elvis_config, Config) of | ||
undefined -> | ||
ConfigFile = filename:join(base_dir(Config), "elvis.config"), | ||
[ fix_dirs(Group, Config) | ||
|| Group <- elvis_config:load_file(ConfigFile)]; | ||
ConfigFile -> elvis_config:load_file(ConfigFile) | ||
end, | ||
|
||
ct:comment("Elvis rocks!"), | ||
ok = elvis:rock(ElvisConfig), | ||
|
||
{comment, ""}. | ||
|
||
base_dir(Config) -> | ||
case test_server:lookup_config(application, Config) of | ||
undefined -> ct:fail("Missing application in Config: ~p", [Config]); | ||
App -> code:lib_dir(App) | ||
end. | ||
|
||
plts(Config) -> | ||
case test_server:lookup_config(plts, Config) of | ||
undefined -> | ||
Wildcard = filename:join(base_dir(Config), "*.plt"), | ||
case filelib:wildcard(Wildcard) of | ||
[] -> | ||
ct:fail("No plts at ~s - you need to at least have one", [Wildcard]); | ||
Plts -> Plts | ||
end; | ||
Plts -> Plts | ||
end. | ||
|
||
fix_dirs(#{dirs := Dirs} = Group, Config) -> | ||
NewDirs = | ||
[filename:join(base_dir(Config), Dir) || Dir <- Dirs], | ||
Group#{dirs := NewDirs}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[ | ||
{ | ||
elvis, | ||
[ | ||
{config, | ||
[#{dirs => ["../../src", "../../test"], | ||
filter => "*.erl", | ||
rules => [{elvis_style, line_length, #{limit => 80, | ||
skip_comments => false}}, | ||
{elvis_style, no_tabs}, | ||
{elvis_style, no_trailing_whitespace}, | ||
{elvis_style, macro_names}, | ||
{elvis_style, macro_module_names}, | ||
{elvis_style, operator_spaces, #{rules => [{right, ","}, | ||
{right, "++"}, | ||
{left, "++"}]}}, | ||
{elvis_style, nesting_level, #{level => 3}}, | ||
{elvis_style, god_modules, #{limit => 25}}, | ||
{elvis_style, no_if_expression}, | ||
{elvis_style, invalid_dynamic_call, #{ignore => [ktn_recipe_verify]}}, | ||
{elvis_style, used_ignored_variable}, | ||
{elvis_style, no_behavior_info}, | ||
{ | ||
elvis_style, | ||
module_naming_convention, | ||
#{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$", | ||
ignore => []} | ||
}, | ||
{ | ||
elvis_style, | ||
function_naming_convention, | ||
#{regex => "^([a-z$][a-z0-9]*_?)*$"} | ||
}, | ||
{elvis_style, state_record_and_type}, | ||
{elvis_style, no_spec_with_records}, | ||
{elvis_style, dont_repeat_yourself, #{min_complexity => 15}}, | ||
{elvis_style, no_debug_call, #{debug_functions => [{ct, pal}]}} | ||
] | ||
}, | ||
#{dirs => ["../.."], | ||
filter => "Makefile", | ||
rules => [{elvis_project, no_deps_master_erlang_mk, #{ignore => []}}, | ||
{elvis_project, protocol_for_deps_erlang_mk, #{ignore => []}}] | ||
}, | ||
#{dirs => ["../.."], | ||
filter => "elvis.config", | ||
rules => [{elvis_project, old_configuration_format}] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
ktn_json, | ||
ktn_lists, | ||
ktn_maps, | ||
ktn_meta_SUITE, | ||
ktn_numbers, | ||
ktn_os, | ||
ktn_random, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-module(ktn_meta_suite_SUITE). | ||
|
||
-include_lib("mixer/include/mixer.hrl"). | ||
-mixin([{ ktn_meta_SUITE | ||
, [ all/0 | ||
, xref/1 | ||
, dialyzer/1 | ||
, elvis/1 | ||
] | ||
}]). | ||
|
||
-export([init_per_suite/1]). | ||
|
||
-type config() :: [{atom(), term()}]. | ||
|
||
-spec init_per_suite(config()) -> config(). | ||
init_per_suite(Config) -> | ||
[ {application, katana} | ||
, {elvis_config, "../../test/elvis.config"} | ||
, {plts, ["../../.katana.plt"]} | ||
| Config | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
-behaviour(gen_fsm). | ||
|
||
-ignore_xref([{ktn_fsm, start, 3}]). | ||
|
||
-export([ start/2 | ||
, state/1 | ||
, contents/1 | ||
|