ignatov / intellij-erlang

Erlang IDE
https://www.jetbrains.com/help/idea/2018.2/getting-started-with-erlang.html
Other
735 stars 120 forks source link

rebar3 eunit: error navigation opens wrong file below _build #780

Open marco-m opened 7 years ago

marco-m commented 7 years ago

With the latest plugin (0.9.930):

How to reproduce:

rebar3 new app pizza
cd pizza
mkdir test
cat > test/pizza_test.erl <<EOF

-module(pizza_test).
-include_lib("eunit/include/eunit.hrl").

failing_test() ->
    ?assert(false).
EOF
/path/to/pizza/_build/test/lib/pizza/test/pizza_test.erl, line 5

If now you click on that line, it will open the wrong file in the editor window (the one below _build)

This means that you will edit the wrong file, re-run the tests, see again the error, re-open the wrong file and your changes have disappeared (because the real sources have been copied again below _build)

Same problem will happen if the test file contains a compilation error, instead than a test failure.

ferd commented 7 years ago

If the error is given with the path from rebar3 then that fix is likely a thing we need to address in rebar3; we've done it for the compiler and dialyzer (only in master for now), but not all paths have been properly rewritten. Not sure all of them can either.

marco-m commented 7 years ago

Ahh, I didn't even think about trying rebar3 itself from the command-line! Here is what happens (using the steps to create the directory outlined in my original post):

$ rebar3 eunit
===> Verifying dependencies...
===> Compiling pizza
===> Performing EUnit tests...
F
Failures:

  1) pizza_test:failing_test/0: module 'pizza_test'
     Failure/Error: ?assert(false)
       expected: true
            got: false
     %% /path/to/pizza/_build/test/lib/pizza/test/pizza_test.erl:6:in `pizza_test:-failing_test/0-fun-0-/0`

This happens on Mac OS X with a fresh (yesterday) rebar3 from git.

So it seems to be a problem of rebar3 itself as you mention, ferd?

ferd commented 7 years ago

Yeah. If you can open an issue there, we've got somewhat more generic code for that kind of error, we'll just have to see if we can hook EUnit in any way to print better paths for us or if it's hopeless.

marco-m commented 7 years ago

Opened https://github.com/erlang/rebar3/issues/1464 on the rebar3 project. Thanks!

marco-m commented 7 years ago

It looks like it will be difficult to fix the problem on rebar3 side, and in addition it is not considered a serious bug (see above mentioned bug on rebar3). I think the only pragmatic approach is to workaround from the intellij-erlang part.