mill icon indicating copy to clipboard operation
mill copied to clipboard

Add test reporter for Kotlin/JS

Open 0xnm opened this issue 1 year ago • 3 comments

This PR adds test reporter for Kotlin/JS. It is based on XUnit reporter provided by Mocha - XML will be generated anyway, irrespective of the TestModule.testReportXml option, because structured output is needed in order to be able to parse it.

So as a result it will be XML file + test result message, which can be seen in the tests.

Adding HTML reporter is not yet possible without using 3rd party packages, because the one provided OOTB by Mocha is not intended for CLI usage.

I also had to modify the Jvm.runSubprocess method, so it doesn't throw if exit code is not 0, but returns result. To comply with the old behavior, all the old call sites will just call getOrThrow on the result.

This change is needed, because if there is a test failure, node process will exit with code 1, but we still need to process and catching generic Exception is not an option (because maybe it is not because of the exit code).

Upd: Binary compatibility check now complains that Jvm.runSubprocess has a different return type, but I'm not sure if it should be a problem, because before it was simply returning Unit. But if it is a problem, I can introduce a new method instead.

0xnm avatar Oct 16 '24 21:10 0xnm

Upd: Binary compatibility check now complains that Jvm.runSubprocess has a different return type, but I'm not sure if it should be a problem, because before it was simply returning Unit. But if it is a problem, I can introduce a new method instead.

Yes let's give the new method a new name to preserve binary compatibility. The old one returning : Unit can just call the new one and ignore the return value

lihaoyi avatar Oct 17 '24 05:10 lihaoyi

Seems like some of the mill.kotlinlib.js.KotlinJSNodeRunTests tests are failing

lihaoyi avatar Oct 20 '24 02:10 lihaoyi

Oh, yeah, indeed, thank for spotting it. I was thinking it was a flaky test from scalalib, but turns out not only it.

This is the case where type safety cannot be checked during the compile time, because Result.Failing is itself Exception.

Fixed now.

0xnm avatar Oct 20 '24 15:10 0xnm