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

kernel: Fix code:get_doc/1,2 when cover_compiled #9433

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

williamthome
Copy link
Contributor

This PR fixes a bug getting docs when a module is compiled by the cover module. Also, the cover_compiled error was missing in the spec.

To reproduce, first compile the module via cover:compile and run code:get_doc.

Find this bug via the new doctest, for example:

% src/otp_doctest
-module(otp_doctest).

-export([foo/0]).

-doc ~"""
```
> otp_doctest:foo().
bar % must fail
```
""".
foo() ->
    foo.
% rebar.config
{profiles, [
    {test, [
        {cover_enabled, true}
    ]}
]}.
% test/otp_doctest_SUITE.erl
-module(otp_doctest_SUITE).
-behaviour(ct_suite).
-compile([export_all, nowarn_export_all]).

all() ->
    [doctests].

doctests(Config) when is_list(Config) ->
    shell_docs:test(otp_doctest, []).

The expected result is to fail, but the test passed:

$ rebar3 ct
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling otp_doctest
===> Running Common Test suites...
%%% otp_doctest_SUITE: .
All 1 tests passed.

After this PR the error is raised:

===> Verifying dependencies...
===> Analyzing applications...
===> Compiling otp_doctest
===> Running Common Test suites...
%%% otp_doctest_SUITE:
%%% otp_doctest_SUITE ==> doctests: FAILED
%%% otp_doctest_SUITE ==> {{badmatch,foo},
 [{erl_eval,expr,6,[{file,"erl_eval.erl"},{line,670}]},
  {shell_docs_test,run_tests,2,[{file,"shell_docs_test.erl"},{line,198}]},
  {lists,foldl,3,[{file,"lists.erl"},{line,2150}]},
  {shell_docs_test,test,2,[{file,"shell_docs_test.erl"},{line,153}]},
  {shell_docs_test,parse_and_run,3,[{file,"shell_docs_test.erl"},{line,137}]},
  {shell_docs_test,'-parse_and_run/3-lc$^0/1-0-',3,
                   [{file,"shell_docs_test.erl"},{line,133}]},
  {shell_docs_test,'-module/2-lc$^0/1-0-',3,
                   [{file,"shell_docs_test.erl"},{line,122}]},
  {shell_docs_test,module,2,[{file,"shell_docs_test.erl"},{line,123}]}]}

cc @garazdawi

Copy link
Contributor

github-actions bot commented Feb 13, 2025

CT Test Results

    2 files     70 suites   1h 7m 53s ⏱️
1 567 tests 1 324 ✅ 243 💤 0 ❌
1 817 runs  1 524 ✅ 293 💤 0 ❌

Results for commit e167d95.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@williamthome williamthome changed the base branch from master to maint February 13, 2025 13:25
@williamthome williamthome changed the base branch from maint to master February 13, 2025 13:25
@williamthome
Copy link
Contributor Author

I think this fix should be in the maint branch, but I changed the base branch and a bunch of commits appeared in this PR.

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants