Skip to content

Commit

Permalink
Assume OTP 24+ for edoc chunk tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Aug 30, 2021
1 parent c147fa9 commit ff3ab2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
10 changes: 2 additions & 8 deletions test/ex_doc/retriever/erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ defmodule ExDoc.Retriever.ErlangTest do
alias ExDoc.{Retriever, DocAST, Language.Erlang}
import TestHelper

@moduletag :otp24

setup :create_tmp_dir

describe "docs_from_modules/2" do
@describetag :otp23

test "module", c do
erlc(c, :mod, ~S"""
%% @doc
Expand Down Expand Up @@ -75,8 +75,6 @@ defmodule ExDoc.Retriever.ErlangTest do
assert function2.specs == []
end

@tag :otp23
@tag :otp24
test "module with no docs is skipped", c do
erlc(c, :mod, ~S"""
-module(mod).
Expand All @@ -85,8 +83,6 @@ defmodule ExDoc.Retriever.ErlangTest do
[] = Retriever.docs_from_modules([:mod], %ExDoc.Config{})
end

@tag :otp23
@tag :otp24
test "function with no docs is skipped", c do
erlc(c, :mod, ~S"""
%% @doc Docs.
Expand All @@ -100,7 +96,6 @@ defmodule ExDoc.Retriever.ErlangTest do
assert mod.docs == []
end

@tag :otp24
test "callbacks", c do
erlc(c, :mod, ~S"""
%% @doc Docs.
Expand Down Expand Up @@ -131,7 +126,6 @@ defmodule ExDoc.Retriever.ErlangTest do
assert optional_callback1.annotations == ["optional"]
end

@tag :otp24
test "types", c do
erlc(c, :mod, ~S"""
%% @doc Docs.
Expand Down
22 changes: 2 additions & 20 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
exclude = [
earmark: not ExDoc.Markdown.Earmark.available?(),
otp23: System.otp_release() < "23",
otp24: System.otp_release() < "24"
]

Expand Down Expand Up @@ -86,25 +85,8 @@ defmodule TestHelper do
)
end
else
def edoc_to_chunk(module) do
source_path = module.module_info(:compile)[:source]
beam_path = :code.which(module)
dir = :filename.dirname(source_path)
xml_path = '#{dir}/#{module}.xml'
chunk_path = '#{dir}/#{module}.chunk'

docgen_priv_dir = :code.priv_dir(:erl_docgen)
cmd!("escript #{docgen_priv_dir}/bin/xml_from_edoc.escript -dir #{dir} #{source_path}")

:docgen_xml_to_chunk.main(["app", xml_path, beam_path, "", chunk_path])
docs_chunk = File.read!(chunk_path)
{:ok, ^module, chunks} = :beam_lib.all_chunks(beam_path)
{:ok, beam} = :beam_lib.build_module([{'Docs', docs_chunk} | chunks])
File.write!(beam_path, beam)
end

defp cmd!(command) do
0 = Mix.shell().cmd(command)
def edoc_to_chunk(_) do
raise "not supported"
end
end

Expand Down

0 comments on commit ff3ab2d

Please sign in to comment.