otp icon indicating copy to clipboard operation
otp copied to clipboard

CT: Add source filename in error output when possible

Open essen opened this issue 3 months ago • 5 comments

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.

essen avatar Oct 08 '25 15:10 essen

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

github-actions[bot] avatar Oct 08 '25 15:10 github-actions[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

michalmuskala avatar Oct 09 '25 10:10 michalmuskala

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?

essen avatar Oct 09 '25 11:10 essen

We could emulate this via <module_name>.erl: or keep the existing format

TheGeorge avatar Oct 09 '25 15:10 TheGeorge

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cowboy_test:gun_open at test/cowboy_test.erl:184 failed
Reason: {badmatch,{error,{no_quicer,"Cowboy must be compiled with en...}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

essen avatar Oct 10 '25 12:10 essen