Skip to content

Conversation

@FinlayRJW
Copy link
Contributor

@FinlayRJW FinlayRJW commented Jan 23, 2026

Before this PR

The TestReportFormattingPlugin relied on internal Gradle APIs (HtmlTestReport, TestReporter, etc.) using reflection to intercept and format test report output. This approach broke frequently across Gradle versions, requiring version-specific reflection hacks for 8.8, 8.11, and now completely
breaking in 9.3.0 where org/gradle/api/internal/tasks/testing/report/HtmlTestReport was removed entirely.

After this PR

Replaces the reflection-heavy internal API approach with a simple post-processing strategy. The plugin now uses FlowScope.always() to run after test tasks complete, walking the generated HTML report directory and reformatting witchcraft log JSON lines in-place. This approach works across all Gradle 8.1+
versions including 9.x without version-specific code

==COMMIT_MSG==
Use post-processing approach for test report formatting to support Gradle 9
==COMMIT_MSG==

Possible downsides?

Drops Gradle 7 support. The post-processing happens after test execution completes rather than during report generation, but the end result is equivalent.

@changelog-app
Copy link

changelog-app bot commented Jan 23, 2026

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

maybe rubbish

Check the box to generate changelog(s)

  • Generate changelog entry


class TestReportFormattingPluginIntegrationSpec extends IntegrationSpec {
private static final List<String> GRADLE_VERSIONS = ["7.6.4", "8.8", GradleVersion.current().getVersion()]
private static final List<String> GRADLE_VERSIONS = ["8.8", GradleVersion.current().getVersion(), "9.3.0"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will disappear when the migration happens. We shoudl probably add a note to the excavator to be like if it is sees this, it should add to the test-versions.yml file

new LogParser<>(TestLogFilter.INSTANCE.combineWith(LogFormatter.INSTANCE, (include, formatted) ->
include ? Optional.of(formatted) : Optional.empty()));

private static final Pattern PRE_PATTERN = Pattern.compile("(<pre[^>]*>)(.*?)(</pre>)", Pattern.DOTALL);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would want you to find the stdout/stderr section, this feels like too big a capture group.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to Match <pre> tags within stdout/stderr sections: <h2>standard output</h2>...<pre>...</pre>

If we think this is a sensible route to go I'll tidy up and migrate the tests etc

@FinlayRJW FinlayRJW changed the title maybe rubbish Use post-processing approach for test report formatting to support Gradle 9 Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants