mirror of
https://github.com/apple/pkl.git
synced 2026-04-25 09:48:41 +02:00
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:
@@ -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.
|
||||
@@ -43,6 +43,13 @@ public abstract class ProjectPackageTask extends BasePklTask {
|
||||
@OutputDirectory
|
||||
public abstract DirectoryProperty getJunitReportsDir();
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
public abstract Property<Boolean> getJunitAggregateReports();
|
||||
|
||||
@Input
|
||||
public abstract Property<String> getJunitAggregateSuiteName();
|
||||
|
||||
@Input
|
||||
public abstract Property<Boolean> getOverwrite();
|
||||
|
||||
@@ -50,6 +57,10 @@ public abstract class ProjectPackageTask extends BasePklTask {
|
||||
@Optional
|
||||
public abstract Property<Boolean> getSkipPublishCheck();
|
||||
|
||||
public ProjectPackageTask() {
|
||||
this.getJunitAggregateSuiteName().convention("pkl-tests");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRunTask() {
|
||||
var projectDirectories =
|
||||
@@ -59,12 +70,15 @@ public abstract class ProjectPackageTask extends BasePklTask {
|
||||
if (projectDirectories.isEmpty()) {
|
||||
throw new InvalidUserDataException("No project directories specified.");
|
||||
}
|
||||
|
||||
new CliProjectPackager(
|
||||
getCliBaseOptions(),
|
||||
projectDirectories,
|
||||
new CliTestOptions(
|
||||
mapAndGetOrNull(getJunitReportsDir(), it -> it.getAsFile().toPath()),
|
||||
getOverwrite().get()),
|
||||
getOverwrite().get(),
|
||||
getJunitAggregateReports().getOrElse(false),
|
||||
getJunitAggregateSuiteName().get()),
|
||||
getOutputPath().get().getAsFile().getAbsolutePath(),
|
||||
getSkipPublishCheck().getOrElse(false),
|
||||
new PrintWriter(System.out),
|
||||
|
||||
@@ -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.
|
||||
@@ -29,16 +29,29 @@ public abstract class TestTask extends ModulesTask {
|
||||
@OutputDirectory
|
||||
public abstract DirectoryProperty getJunitReportsDir();
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
public abstract Property<Boolean> getJunitAggregateReports();
|
||||
|
||||
@Input
|
||||
public abstract Property<String> getJunitAggregateSuiteName();
|
||||
|
||||
@Input
|
||||
public abstract Property<Boolean> getOverwrite();
|
||||
|
||||
public TestTask() {
|
||||
this.getJunitAggregateSuiteName().convention("pkl-tests");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRunTask() {
|
||||
new CliTestRunner(
|
||||
getCliBaseOptions(),
|
||||
new CliTestOptions(
|
||||
mapAndGetOrNull(getJunitReportsDir(), it -> it.getAsFile().toPath()),
|
||||
getOverwrite().get()),
|
||||
getOverwrite().get(),
|
||||
getJunitAggregateReports().getOrElse(false),
|
||||
getJunitAggregateSuiteName().get()),
|
||||
new PrintWriter(System.out),
|
||||
new PrintWriter(System.err))
|
||||
.run();
|
||||
|
||||
Reference in New Issue
Block a user