Aggregate junit report into one file (#1056)

Some systems require junit report to be in a single file. For example `bazel` https://bazel.build/reference/test-encyclopedia needs single file to be available in `XML_OUTPUT_FILE` path.

To avoid implementing junit aggregation in pkl wrappers in different places this PR instead adds a `--junit-aggregate-reports` flag to return all junit reports as a single file.

Additional flag `--junit-aggregate-suite-name` is added to allow overriding global test suite name from default `pkl-tests`
This commit is contained in:
Artem Yarmoliuk
2025-06-07 01:33:13 +01:00
committed by GitHub
parent 0b0f3b131d
commit 3bd8a88506
11 changed files with 353 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,4 +17,9 @@ package org.pkl.commons.cli
import java.nio.file.Path
class CliTestOptions(val junitDir: Path? = null, val overwrite: Boolean = false)
class CliTestOptions(
val junitDir: Path? = null,
val overwrite: Boolean = false,
val junitAggregateReports: Boolean = false,
val junitAggregateSuiteName: String = "pkl-tests",
)

View File

@@ -16,6 +16,7 @@
package org.pkl.commons.cli.commands
import com.github.ajalt.clikt.parameters.groups.OptionGroup
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.path
@@ -31,8 +32,26 @@ class TestOptions : OptionGroup() {
)
.path()
private val junitAggregateReports: Boolean by
option(
names = arrayOf("--junit-aggregate-reports"),
help = "Aggregate JUnit reports into a single file.",
)
.flag()
private val junitAggregateSuiteName: String by
option(
names = arrayOf("--junit-aggregate-suite-name"),
metavar = "name",
help = "The name of the root JUnit test suite.",
)
.single()
.default("pkl-tests")
private val overwrite: Boolean by
option(names = arrayOf("--overwrite"), help = "Force generation of expected examples.").flag()
val cliTestOptions: CliTestOptions by lazy { CliTestOptions(junitReportDir, overwrite) }
val cliTestOptions: CliTestOptions by lazy {
CliTestOptions(junitReportDir, overwrite, junitAggregateReports, junitAggregateSuiteName)
}
}