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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/compiler/test/beam_doc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
private_types/1, export_all/1, equiv/1, spec/1, deprecated/1, warn_missing_doc/1,
doc_with_file/1, doc_with_file_error/1, all_string_formats/1,
docs_from_ast/1, spec_switch_order/1, user_defined_type/1, skip_doc/1,
no_doc_attributes/1, converted_metadata/1, converted_metadata_warnings/1]).
no_doc_attributes/1, converted_metadata/1, converted_metadata_warnings/1,
cover_compiled/1]).

-include_lib("common_test/include/ct.hrl").
-include_lib("kernel/include/eep48.hrl").
Expand Down Expand Up @@ -55,7 +56,8 @@
skip_doc,
no_doc_attributes,
converted_metadata,
converted_metadata_warnings
converted_metadata_warnings,
cover_compiled
].

singleton_moduledoc(Conf) ->
Expand Down Expand Up @@ -694,6 +696,18 @@

ok.

cover_compiled(Config) ->
DataDir = proplists:get_value(data_dir, Config),
ok = file:set_cwd(DataDir),

ModuleName = ?get_name(),
{ok, ModName} = default_compile_file(Config, ModuleName),
{ok, cover_compiled} = cover:compile(ModuleName),

{ok, #docs_v1{}} = code:get_doc(ModName),

ok.

scan_and_parse(Code) ->
{ok, Toks, _} = erl_scan:string(Code),
parse(Toks).
Expand Down Expand Up @@ -733,7 +747,7 @@

%% Verify that all doc and moduledoc attributes are stripped from debug_info
check_no_doc_attributes(Mod) ->
{ok, {_ModName,

Check warning on line 750 in lib/compiler/test/beam_doc_SUITE.erl

View workflow job for this annotation

GitHub Actions / CT Test Results

cover_compiled failed

artifacts/Unit Test Results/compiler_junit.xml [took 0s]
Raw output
Test cover_compiled in beam_doc_SUITE failed!
{{badmatch,{error,beam_lib,{file_error,"non_existing.beam",enoent}}},
 [{beam_doc_SUITE,check_no_doc_attributes,1,
                  [{file,"beam_doc_SUITE.erl"},{line,750}]},
  {beam_doc_SUITE,compile_file,3,[{file,"beam_doc_SUITE.erl"},{line,729}]},
  {beam_doc_SUITE,source_path,1,[{file,"beam_doc_SUITE.erl"},{line,174}]},
  {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
  {test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1303}]},
  {test_server,run_test_case_eval,9,[{file,"test_server.erl"},{line,1235}]}]}
[{debug_info,
{debug_info_v1,erl_abstract_code,
{AST, Opts}}}]}} = beam_lib:chunks(Mod, [debug_info]),
Expand Down
7 changes: 7 additions & 0 deletions lib/compiler/test/beam_doc_SUITE_data/cover_compiled.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-module(cover_compiled).
-moduledoc ~"""
cover_compiled
""".

% SPDX-License-Identifier: Apache-2.0
% SPDX-FileCopyrightText: 2025 Erlang/OTP and contributors
9 changes: 9 additions & 0 deletions lib/kernel/src/code.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,15 @@ get_doc(Mod, #{sources:=[Source|Sources]}=Options) ->
ErtsDir ->
GetDoc(filename:join([ErtsDir, "ebin", atom_to_list(Mod) ++ ".beam"]))
end;
cover_compiled ->
case which(Mod, get_path()) of
non_existing ->
{error, missing};
Error when is_atom(Error) ->
{error, Error};
Fn when is_list(Fn) ->
GetDoc(Fn)
end;
Error when is_atom(Error) ->
{error, Error};
Fn ->
Expand Down
Loading