Skip to content

Commit

Permalink
Merge pull request #76 from qhool/maybe_optional
Browse files Browse the repository at this point in the history
Un-break katana for projects that do not enable maybe_expr
  • Loading branch information
elbrujohalcon authored Mar 17, 2023
2 parents b6b6e77 + 99c5079 commit 689d81d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:

build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04

strategy:
matrix:
Expand Down Expand Up @@ -34,6 +34,8 @@ jobs:
run: ERL_FLAGS="-enable-feature all" rebar3 compile
- name: Format check
run: ERL_FLAGS="-enable-feature all" rebar3 format --verify
- name: Run tests and verifications
- name: Run tests and verifications (features not enabled)
run: rebar3 test
- name: Run tests and verifications (features enabled)
run: ERL_FLAGS="-enable-feature all" rebar3 test

8 changes: 1 addition & 7 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
%% -*- mode: erlang;erlang-indent-level: 2;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
{erl_opts,
[warn_unused_import,
warn_export_vars,
warnings_as_errors,
verbose,
report,
debug_info,
{feature, maybe_expr, enable}]}.
[warn_unused_import, warn_export_vars, warnings_as_errors, verbose, report, debug_info]}.

{minimum_otp_vsn, "23"}.

Expand Down
19 changes: 18 additions & 1 deletion test/ktn_code_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
-spec all() -> [atom()].
all() ->
Exports = ?MODULE:module_info(exports),
[F || {F, _} <- Exports, not lists:member(F, ?EXCLUDED_FUNS)].
%% Do not test maybe expressions if the feature is not enabled in the emulator
DisabledMaybeTests =
case lists:member(maybe_expr, enabled_features()) of
true ->
[];
false ->
[parse_maybe, parse_maybe_else]
end,
Excluded = ?EXCLUDED_FUNS ++ DisabledMaybeTests,
[F || {F, _} <- Exports, not lists:member(F, Excluded)].

-spec init_per_suite(config()) -> config().
init_per_suite(Config) ->
Expand All @@ -33,6 +42,14 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
Config.

enabled_features() ->
try
erl_features:enabled()
catch
error:undef ->
[]
end.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test Cases
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down

0 comments on commit 689d81d

Please sign in to comment.