Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERL-1326: Common Test: empty groups should not fail #4362

Closed
OTP-Maintainer opened this issue Aug 4, 2020 · 2 comments · Fixed by #7919
Closed

ERL-1326: Common Test: empty groups should not fail #4362

OTP-Maintainer opened this issue Aug 4, 2020 · 2 comments · Fixed by #7919
Assignees
Labels
enhancement help wanted Issue not worked on by OTP; help wanted from the community priority:medium team:PS Assigned to OTP team PS

Comments

@OTP-Maintainer
Copy link

Original reporter: JIRAUSER15901
Affected version: OTP-23
Component: common_test
Migrated from: https://bugs.erlang.org/browse/ERL-1326


*Sample code*

{code:erlang}
-module(example_SUITE).
-include_lib("stdlib/include/assert.hrl").

-compile(export_all).

all() -> [{group, g1}, {group, g2}].

groups() -> [{g1, [t1]}, {g2, []}].

t1(_Config) ->
  ok.
{code}

*Current functionality*

{{ct_run -suite example_SUITE}}

At present, running this command will cause ct to fail with error "Invalid reference to group g2 in example_SUITE:all/0"

*Improvement suggestion*

This example should not generate an error. An empty list of tests is a valid list. It could be silently skipped instead.

*Motivation*

If you evaluate {{[length(X) || X <- [[1, 2], [], [3]]].}}, you do not expect an error.

A group could be temporarily empty, and it's inconvenient when tests fail based on that.
@OTP-Maintainer
Copy link
Author

paulo.ferraz.oliveira@gmail.com said:

I also ran into this very issue (which causes a silent {{rebar3}} to exit without warnings) and a potentially related one:
 * {{ct:run_test/1}} will not output \{error, _} in this very same case, but instead {{{Ok, Failed, {UserSkipped, AutoSkipped}} = \{0, 0, {0, 0}}}}.

@OTP-Maintainer
Copy link
Author

paulo.ferraz.oliveira@gmail.com said:

Somewhat related:
 I had my group specified as {ok, [sequence], \{handle_for}} (handle_for should be in a list) and again the issue was silent.

@OTP-Maintainer OTP-Maintainer added enhancement help wanted Issue not worked on by OTP; help wanted from the community team:PS Assigned to OTP team PS priority:medium labels Feb 10, 2021
jchristgit added a commit to jchristgit/otp that referenced this issue Nov 30, 2023
The logic to trim empty test cases was moved from the find groups
function (which will now also return groups with no testcases) to the
expand groups function. Groups with no testcases will not be run (e.g.
their init_per_group and end_per_group functions will not be called),
but no error will be thrown as previously.

Fixes erlang#4362.
jchristgit added a commit to jchristgit/otp that referenced this issue Dec 1, 2023
The logic to trim empty test cases was moved from the find groups
function (which will now also return groups with no testcases) to the
expand groups function. Groups with no testcases will not be run (e.g.
their init_per_group and end_per_group functions will not be called),
but no error will be thrown as previously.

Fixes erlang#4362.
@u3s u3s closed this as completed in 883d52f Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Issue not worked on by OTP; help wanted from the community priority:medium team:PS Assigned to OTP team PS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants