Skip to content

In memory modules aren't supported #299

@hauleth

Description

@hauleth

Describe the bug

Concuerror silently fails on in-memory modules.

To Reproduce

%% Define module in memory

Module = erl_syntax:attribute(erl_syntax:atom(module),[erl_syntax:atom(sample)]).
ModForm =  erl_syntax:revert(Module).

Export = erl_syntax:attribute(erl_syntax:atom(export),[erl_syntax:list([erl_syntax:arity_qualifier(erl_syntax:atom(test),erl_syntax:integer(0))])]).
ExportForm = erl_syntax:revert(Export).

% define the function body
Body = erl_syntax:atom(nil).

% define the first clause
Clause =  erl_syntax:clause([],[],[Body]).

% define the function
Function =  erl_syntax:function(erl_syntax:atom(test),[Clause]).
FunctionForm = erl_syntax:revert(Function).

{ok, Mod, Bin1} = compile:forms([ModForm,ExportForm, FunctionForm]).
code:load_binary(Mod, [], Bin1).

%% Now run concuerror on it

concuerror:run([{module, sample}]).

This will success but there will be information that module cannot be loaded, which in fact mean that it silently does nothing.

Expected behavior

It should run tests.

It could fail, but it would be infeasible, as Elixir tests are defined in way similar to this, which makes testing them with concuerror quite troublesome (you need to create additional module in separate file (that is compiled) and only then you can run test on it).

Environment (please complete the following information):

  • OS: macOS
  • Concuerror Version: master

Additional context

This was found when tried to run Concuerror tests on Elixir tests.

Example Elixir code:

defmodule ConcuerrorElixirExampleTest do
  def message_test do
    this = self()
    spawn(fn -> send(this, :foo) end)
    spawn(fn -> send(this, :bar) end)

    receive do
      msg -> :foo = msg
    end
  end
end

:ok = :concuerror.run(module: ConcuerrorElixirExampleTest, test: :message_test)

This must be saved as file with .exs extension and ran via elixir file.exs to reproduce error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions