Skip to content

Commit 9014c2a

Browse files
authored
Merge pull request #2577 from Gedochao/maintenance/fix-it-test-reports
Adjust test report generation to mill 0.11.6 bump changes
2 parents 1e0f850 + ba38581 commit 9014c2a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.github/scripts/generate-junit-reports.sc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def findFiles(paths: Seq[os.Path], result: Seq[os.Path] = Nil): Seq[os.Path] =
2727
case Nil => result
2828
case head :: tail =>
2929
val newFiles =
30-
if head.last == "test.dest" && os.isDir(head) then
30+
if head.segments.contains("test") && head.last.endsWith(".dest") && os.isDir(head) then
3131
os.list(head).filter(f => f.last == "out.json").toList
3232
else Seq.empty
3333
val newDirs = os.list(head).filter(p => os.isDir(p)).toList
@@ -62,6 +62,10 @@ if !os.isDir(rootPath) then {
6262
val reports: Seq[os.Path] = findFiles(Seq(rootPath))
6363
println(s"Found ${reports.length} mill json reports:")
6464
println(reports.mkString("\n"))
65+
if reports.isEmpty then {
66+
println("Error: no reports found!")
67+
System.exit(1)
68+
}
6569
println("Reading reports...")
6670
val tests: Seq[Test] = reports.map(x => ujson.read(x.toNIO)).flatMap { json =>
6771
json(1).value.asInstanceOf[ArrayBuffer[ujson.Obj]].map { test =>
@@ -87,6 +91,10 @@ val tests: Seq[Test] = reports.map(x => ujson.read(x.toNIO)).flatMap { json =>
8791
}
8892
}
8993
println(s"Found ${tests.length} tests.")
94+
if tests.isEmpty then {
95+
println("Error: no tests found!")
96+
System.exit(1)
97+
}
9098
println("Generating JUnit XML report...")
9199
val suites = tests.groupBy(_.fullyQualifiedName).map { case (suit, tests) =>
92100
val testcases = tests.map { test =>

DEV.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ The debug option uses 5005 port by default. It is possible to change it as follo
7474
./mill integration.test.native 'scala.cli.integration.RunTestsDefault.*'
7575
```
7676

77+
#### Generate JUnit test reports
78+
79+
As running tests with mill generates output in a non-standard JSON format, we have a script for converting it to the
80+
more well known JUnit XML test report format which we can then process and view on the CI.
81+
In case you want to generate a test report locally, you can run the following command:
82+
83+
```bash
84+
.github/scripts/generate-junit-reports.sc <test suite title> <test report title> <output-path out/
85+
```
86+
87+
The test should fail when no test reports were found or if no tests were actually run.
88+
7789
#### Generate native packages
7890

7991
Build native packagers:

0 commit comments

Comments
 (0)