Skip to content

Return [{mod, bin}] from Code.compile_file/2, require_file/2, load_file/2 #9864

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

Merged
merged 1 commit into from
Feb 29, 2020
Merged
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
2 changes: 1 addition & 1 deletion lib/elixir/lib/code.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,6 @@ defmodule Code do
defp verify_loaded(loaded) do
maps_binaries = Enum.map(loaded, fn {_module, map, binary} -> {map, binary} end)
Module.ParallelChecker.verify(maps_binaries, [])
Enum.map(loaded, fn {module, map, _binary} -> {module, map} end)
Enum.map(loaded, fn {module, _map, binary} -> {module, binary} end)
end
end
15 changes: 13 additions & 2 deletions lib/elixir/test/elixir/code_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,18 @@ defmodule CodeTest do
test "compile_file/1" do
assert Code.compile_file(fixture_path("code_sample.exs")) == []
refute fixture_path("code_sample.exs") in Code.required_files()

assert [{CompileSample, binary}] = Code.compile_file(fixture_path("compile_sample.ex"))
assert is_binary(binary)
after
:code.purge(CompileSample)
:code.delete(CompileSample)
end

test "compile_file/1 also emits checker warnings" do
output =
ExUnit.CaptureIO.capture_io(:stderr, fn ->
Code.compile_file(PathHelpers.fixture_path("checker_warning.exs"))
Code.compile_file(fixture_path("checker_warning.exs"))
end)

assert output =~ "incompatible types"
Expand All @@ -122,8 +128,13 @@ defmodule CodeTest do
Code.unrequire_files([fixture_path("code_sample.exs")])
refute fixture_path("code_sample.exs") in Code.required_files()
assert Code.require_file(fixture_path("code_sample.exs")) != nil

assert [{CompileSample, binary}] = Code.require_file(fixture_path("compile_sample.ex"))
assert is_binary(binary)
after
Code.unrequire_files([fixture_path("code_sample.exs")])
Code.unrequire_files([fixture_path("code_sample.exs"), fixture_path("compile_sample.ex")])
:code.purge(CompileSample)
:code.delete(CompileSample)
end

describe "string_to_quoted/2" do
Expand Down