Skip to content

Commit 689d81d

Browse files
Merge pull request #76 from qhool/maybe_optional
Un-break katana for projects that do not enable maybe_expr
2 parents b6b6e77 + 99c5079 commit 689d81d

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66

77
build:
88

9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-20.04
1010

1111
strategy:
1212
matrix:
@@ -34,6 +34,8 @@ jobs:
3434
run: ERL_FLAGS="-enable-feature all" rebar3 compile
3535
- name: Format check
3636
run: ERL_FLAGS="-enable-feature all" rebar3 format --verify
37-
- name: Run tests and verifications
37+
- name: Run tests and verifications (features not enabled)
38+
run: rebar3 test
39+
- name: Run tests and verifications (features enabled)
3840
run: ERL_FLAGS="-enable-feature all" rebar3 test
3941

rebar.config

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
%% -*- mode: erlang;erlang-indent-level: 2;indent-tabs-mode: nil -*-
22
%% ex: ts=4 sw=4 ft=erlang et
33
{erl_opts,
4-
[warn_unused_import,
5-
warn_export_vars,
6-
warnings_as_errors,
7-
verbose,
8-
report,
9-
debug_info,
10-
{feature, maybe_expr, enable}]}.
4+
[warn_unused_import, warn_export_vars, warnings_as_errors, verbose, report, debug_info]}.
115

126
{minimum_otp_vsn, "23"}.
137

test/ktn_code_SUITE.erl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@
2323
-spec all() -> [atom()].
2424
all() ->
2525
Exports = ?MODULE:module_info(exports),
26-
[F || {F, _} <- Exports, not lists:member(F, ?EXCLUDED_FUNS)].
26+
%% Do not test maybe expressions if the feature is not enabled in the emulator
27+
DisabledMaybeTests =
28+
case lists:member(maybe_expr, enabled_features()) of
29+
true ->
30+
[];
31+
false ->
32+
[parse_maybe, parse_maybe_else]
33+
end,
34+
Excluded = ?EXCLUDED_FUNS ++ DisabledMaybeTests,
35+
[F || {F, _} <- Exports, not lists:member(F, Excluded)].
2736

2837
-spec init_per_suite(config()) -> config().
2938
init_per_suite(Config) ->
@@ -33,6 +42,14 @@ init_per_suite(Config) ->
3342
end_per_suite(Config) ->
3443
Config.
3544

45+
enabled_features() ->
46+
try
47+
erl_features:enabled()
48+
catch
49+
error:undef ->
50+
[]
51+
end.
52+
3653
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3754
%% Test Cases
3855
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0 commit comments

Comments
 (0)