CT: Add source filename in error output when possible
PoC for https://github.com/erlang/otp/issues/10260
I figured that I would get the filename from the same place exceptions already do since it's the most appropriate and there's no need to tweak the filename. With this filename I could then have GitHub annotate PRs with the exact failure location.
In the shell it looks like this:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
compress_SUITE:gzip_accept_encoding_malformed (test/compress_SUITE.erl) failed on line 75
Reason: {badmatch,2}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Or
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cowboy_test:gun_open (test/cowboy_test.erl) failed on line 184
Reason: {badmatch,{error,{no_quicer,"Cowboy must be compiled with en...}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I haven't added tests, let's see if this is an approach that would be OK first.
CT Test Results
2 files 57 suites 1h 15m 39s ⏱️ 451 tests 436 ✅ 15 💤 0 ❌ 485 runs 467 ✅ 18 💤 0 ❌
Results for commit df73e4a6.
:recycle: This comment has been updated with latest results.
To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.
See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.
Artifacts
// Erlang/OTP Github Action Bot
With the same logic as in https://github.com/erlang/otp/pull/9468, it would likely be better to have the format as path/to/file:LINE - many tools recognise that and make it "clickable". This would also align the format with compiler errors and stack trace printing (since OTP 28).
cc @TheGeorge
Sure, we could do that when we have a filename. What if we don't, do we keep the error message as it is now?
We could emulate this via <module_name>.erl:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cowboy_test:gun_open at test/cowboy_test.erl:184 failed
Reason: {badmatch,{error,{no_quicer,"Cowboy must be compiled with en...}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -