eproxus / meck

A mocking library for Erlang
http://eproxus.github.io/meck
Apache License 2.0
811 stars 231 forks source link

Warnings in cover server when mecking distributed nodes with rebar3 do eunit,ct #208

Closed Kuroneer closed 4 years ago

Kuroneer commented 4 years ago

While running rebar3 eunit+distributed ct with meck, I see

%%% mylib_SUITE: WARNING: remote cover_server received
{<23417.96.0>,{is_compiled,mylib}}

in the stdout. I've triaged it to https://github.com/eproxus/meck/blob/3d70c4ea4b38699667a1bfea30df00f98ea11ef0/src/meck_proc.erl#L426 In this case, CT Slave nodes do not run a full cover server, but a "remote cover server", which is unable to handle this call and thus, prints the message it receives: https://github.com/erlang/otp/blob/6eb8890dd255c862a2dee539e1691011005fd5aa/lib/tools/src/cover.erl#L989-L990 Fortunately, at this point this issue is only cosmetic, although no cover data is backed.

I don't know If I should setup meck differently for distributed tests, but as I have it, it could be solved with different approaches:

  1. Call cover:get_main_node/0, but the code of that function states
    %% Used by test_server only. Not documented.
    get_main_node() ->

    so I'm reluctant to use it.

  2. Include an option to disregard cover altogether for one module when calling meck:new
  3. Have some way to provide the master node to meck and use a rpc to that node (where cover is able to answer the is_compiled)
  4. Ignore this issue completely.

Since I don't know which way would be the best, I haven't created a PR yet, I'd gladly do that if required. I've created a sample project where this is shown

Reproduction Steps

  1. clone https://github.com/Kuroneer/meck-test
  2. $ meck-test && rebar test

Expected behavior

Only test output in stdout

Observed behavior

Cover warnings in stdout

Versions

eproxus commented 4 years ago

I would spontaneously lean towards no. 4 since this seems to be an issue with Cover printing random stuff to standard out.

Did I correctly understand it that there should be cover info for this module but it is not retrievable for some reason? Or it doesn't exist in the first place and Cover just prints this annoying message?

Kuroneer commented 4 years ago

Fair enough

In the test case I provided, there was no cover requested (just the annoying message), but I've updated the example repository (f8106a1) to show also the cover issues.