Skip to content

Commit bf7e217

Browse files
committed
Fail test report generation for when there are no tests to report
1 parent c948777 commit bf7e217

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 =>

0 commit comments

Comments
 (0)