Skip to content

Commit

Permalink
common_test: abort_if_missing_suites defaults to true
Browse files Browse the repository at this point in the history
  • Loading branch information
u3s committed Nov 14, 2024
1 parent 171fb25 commit 051db45
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 13 deletions.
23 changes: 13 additions & 10 deletions lib/common_test/doc/guides/run_test_chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ suites are compiled. If a particular test object directory is specified (meaning
all suites in this directory are to be part of the test), `Common Test` runs
function `make:all/1` in the directory to compile the suites.

If compilation fails for one or more suites, the compilation errors are printed
to tty and the operator is asked if the test run is to proceed without the
missing suites, or be aborted. If the operator chooses to proceed, the tests
having missing suites are noted in the HTML log. If `Common Test` is unable to
prompt the user after compilation failure (if `Common Test` does not control
`stdin`), the test run proceeds automatically without the missing suites. This
behavior can however be modified with the `ct_run` flag
`-abort_if_missing_suites`, or the `ct:run_test/1` option
`{abort_if_missing_suites,TrueOrFalse}`. If `abort_if_missing_suites` is set to
`true`, the test run stops immediately if some suites fail to compile.
If compilation fails for one or more suites, the test run stops
immediately if some suites fail to compile. This behavior can however
be modified with the `ct_run` flag `-abort_if_missing_suites`, or the
`ct:run_test/1` option `{abort_if_missing_suites,TrueOrFalse}`.Option
`abort_if_missing_suites` is set to `true` by default.

If `abort_if_missing_suites` is set to `false`, the compilation errors
are printed to tty and the operator is asked if the test run is to
proceed without the missing suites, or be aborted. If the operator
chooses to proceed, the tests having missing suites are noted in the
HTML log. If `Common Test` is unable to prompt the user after
compilation failure (if `Common Test` does not control `stdin`), the
test run proceeds automatically without the missing suites.

Any help module (that is, regular Erlang module with name not ending with
"\_SUITE") that resides in the same test object directory as a suite, which is
Expand Down
4 changes: 2 additions & 2 deletions lib/common_test/src/ct_run.erl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ script_start1(Parent, Args) ->
AbortIfMissing = get_start_opt(abort_if_missing_suites,
fun([]) -> true;
([Bool]) -> list_to_atom(Bool)
end, false, Args),
end, true, Args),
%% silent connections
SilentConns =
get_start_opt(silent_connections,
Expand Down Expand Up @@ -1036,7 +1036,7 @@ run_test2(StartOpts) ->
end,

%% abort test run if some suites can't be compiled
AbortIfMissing = get_start_opt(abort_if_missing_suites, value, false,
AbortIfMissing = get_start_opt(abort_if_missing_suites, value, true,
StartOpts),

%% decrypt config file
Expand Down
2 changes: 1 addition & 1 deletion lib/common_test/test/ct_error_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ no_compile(Config) when is_list(Config) ->
Join = fun(D, S) -> filename:join(D, "error/test/"++S) end,
Suites = [Join(DataDir, "no_compile_SUITE")],
{Opts,ERPid} = setup([{suite,Suites}], Config),
ok = ct_test_support:run(Opts, Config),
{error, {make_failed, _}} = ct_test_support:run(Opts, Config),
Events = ct_test_support:get_events(ERPid, Config),

ct_test_support:log_events(no_compile,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
%%--------------------------------------------------------------------
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2024. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%
-module(skip_all_surefire_SUITE).

-compile([export_all, nowarn_export_all]).

-include_lib("common_test/include/ct.hrl").

suite() ->
[{timetrap,{seconds,30}}].

init_per_suite(Config) ->
Config.

end_per_suite(_Config) ->
ok.

init_per_group(_GroupName, Config) ->
Config.

end_per_group(_GroupName, _Config) ->
ok.

init_per_testcase(_TestCase, Config) ->
Config.

end_per_testcase(_TestCase, _Config) ->
ok.

groups() ->
[].

all() ->
[my_test_case].

my_test_case() ->
[].

my_test_case(_Config) ->
ok.

0 comments on commit 051db45

Please sign in to comment.