sormuras / junit-platform-maven-plugin

Maven Plugin launching the JUnit Platform
Apache License 2.0
61 stars 15 forks source link

Add charset configuration #116

Closed dbwiddis closed 10 months ago

dbwiddis commented 11 months ago

Allows user to override Java default charset when printing logs, to work around MalformedInputExceptions.

Fixes #115

This contribution is my original work and I license the work to the project under the project's open source license.

sormuras commented 11 months ago

Almost there... only the Windows runner reports:

...
[INFO] UTF-8 degree sign is °
...
[ERROR] Expected lines don't match this build.log!
> fast-forward(∞) didn't find: `\Q[INFO]\E UTF-8[...]`
...
dbwiddis commented 11 months ago

Almost there... only the Windows runner reports ...

Yeah, I based my test on a UTF-8 character (0xc2b0) but the UTF-16 byte implementation (0x00b0) is different so it results in different output in ISO-8859-1. So I need to find a non-ASCII character with the same 2-byte UTF-8 and UTF-16 implementation, or maybe use a regex to allow either c2 or 00 for that byte.

sormuras commented 11 months ago

[...] or maybe use a regex to allow either c2 or 00 for that byte.

Fine with me.

dbwiddis commented 11 months ago

Turns out the ISO charset just skips null bytes so this works out to an optional \uc2 character in the regex.

dbwiddis commented 11 months ago

OK, I think I'm done... the MIE is thrown in Files.lines() so isn't caught by the log reading IOException (which looks like it just warns and doesn't fail the test). Can add it to the outer catch but then it doesn't have access to exitValue. I expanded the scope of exit value but perhaps it's a better idea to keep the original try/catch for the log reading and wrap a try-with-resources block inside that (with no catch block).

dbwiddis commented 11 months ago

OK I really am done now, unless you have changes requested. :)