Skip to content

Document TestKit coverage for external consumers, raise coverage - #175

Merged
alexander-yevsyukov merged 12 commits into
masterfrom
update-config-and-testkit-coverage
Jun 7, 2026
Merged

Document TestKit coverage for external consumers, raise coverage#175
alexander-yevsyukov merged 12 commits into
masterfrom
update-config-and-testkit-coverage

Conversation

@alexander-yevsyukov

@alexander-yevsyukov alexander-yevsyukov commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

What changed

  • plugin-testlib — TestKit coverage docs. Added a consumer-facing "Enabling TestKit coverage from your build" section to the enableTestKitCoverage KDoc in plugin-testlib/.../TestKitCoverage.kt. It documents the two system properties the harness consumes (io.spine.tools.gradle.testkit.coverage.agent / …execDir) and provides a self-contained, provider-neutral Gradle Kotlin DSL recipe so users without Spine's config/buildSrc can wire up TestKit coverage themselves. The two property-constant KDocs were generalized to read correctly for non-Spine consumers. The JaCoCo agent in the snippet is pinned to 0.8.15, matching the bumped Jacoco.version.
  • Test coverage → 95.5%. Added and extended unit tests across jvm-tools, plugin-base, psi-java, psi, plugin-testlib, and protobuf-setup-plugins, raising total line coverage from ~80% to 95.48% (Kover aggregate, generated code excluded). Tests-only — no production code changes. This also exercises the TestKit worker-coverage path documented above for the Gradle-plugin modules. Notably, ResourceDirectorySpec had a backtick top-level class name containing spaces that Gradle's test detector silently skipped (so the suite never ran); it was renamed to a valid identifier with @DisplayName. Remaining uncovered lines are non-actionable (inline functions, unreachable catch/guard branches, message lambdas).
  • Update config. A broad dependency refresh under buildSrc/src/main/kotlin/io/spine/dependency/** (including JaCoCo → 0.8.15), buildSrc/build.gradle.kts, a buildSrc TestKitCoverage.kt tweak.

Why

  • plugin-testlib is a library for testing Gradle plugins. Its consumers may not have Spine's config/buildSrc, where io.spine.gradle.testing.enableTestKitCoverage lives. The previous KDoc only pointed at that internal extension, leaving external users with no setup instructions.

  • The new tests put the TestKit worker-coverage harness to work: with out-of-process plugin execution now credited, the Gradle-plugin modules could be brought up alongside the rest of the codebase to a 95%+ total.

Other notable changes

  • Test coverage was raised.

🤖 Generated with Claude Code
🙌 Edited by @alexander-yevsyukov

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f525558b29

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugin-testlib/src/main/kotlin/io/spine/tools/gradle/testing/TestKitCoverage.kt Outdated
Mirror the buildSrc helper in the public KDoc recipe: wipe the exec
directory at most once per build via an AtomicBoolean one-shot guard, and
mark the Test tasks non-cacheable. Without the guard, a module with more
than one TestKit Test task would have each task's doFirst delete the
shared exec file, so only the last task's worker coverage survived.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alexander-yevsyukov alexander-yevsyukov changed the title Document TestKit coverage for external consumers; refresh config dependencies Document TestKit coverage for external consumers; refresh dependencies via config Jun 6, 2026
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.22%. Comparing base (0e172a0) to head (cddd019).

Additional details and impacted files
@@              Coverage Diff              @@
##             master     #175       +/-   ##
=============================================
+ Coverage     73.91%   90.22%   +16.31%     
- Complexity      453      552       +99     
=============================================
  Files           122      122               
  Lines          2231     2230        -1     
  Branches        311      311               
=============================================
+ Hits           1649     2012      +363     
+ Misses          455       96      -359     
+ Partials        127      122        -5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make Gradle TestKit worker coverage (via JaCoCo) understandable and reproducible for external consumers of plugin-testlib, while also bumping the repo snapshot version and regenerating dependency reports after a dependency refresh coming from the shared config/buildSrc setup.

Changes:

  • Expanded KDoc in plugin-testlib to document how TestKit coverage is enabled via two system properties and provided a copy-pastable Gradle Kotlin DSL wiring snippet.
  • Bumped published snapshot version to 2.0.0-SNAPSHOT.395 and regenerated docs/dependencies/pom.xml accordingly.
  • Refreshed a broad set of dependency/version constants and related build wiring under buildSrc (config-distributed).

Reviewed changes

Copilot reviewed 56 out of 57 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.gradle.kts Bumps versionToPublish to 2.0.0-SNAPSHOT.395.
plugin-testlib/src/main/kotlin/io/spine/tools/gradle/testing/TestKitCoverage.kt Adds consumer-oriented documentation and a Gradle Kotlin DSL snippet for enabling TestKit worker coverage.
docs/dependencies/pom.xml Updates snapshot version and dependency versions in the generated dependency report.
buildSrc/src/main/kotlin/io/spine/gradle/testing/TestKitCoverage.kt Updates TestKit coverage wiring behavior/docs in buildSrc (config-distributed).
buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt Adjusts ErrorProne configuration API usage; updates copyright year.
buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt Updates Truth version constant.
buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt Updates Kotlin compile testing fork version constant.
buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt Updates JUnit BOM/Jupiter version constants and legacy JUnit 4 version.
buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt Updates JaCoCo version constant.
buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt Updates Validation snapshot version constant.
buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt Updates ToolBase snapshot versions used by builds/tests.
buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt Updates Core JVM compiler snapshot versions.
buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt Updates Compiler fallback snapshot versions.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Slf4J.kt Updates SLF4J version constant and adds a Maven Central reference comment.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt Updates Roaster version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt Updates Protobuf and protobuf-gradle-plugin version constants.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Plexus.kt Updates plexus-utils version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/PalantirJavaFormat.kt Updates Palantir Java Format version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Okio.kt Updates Okio version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Netty.kt Updates Netty version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Log4j2.kt Updates Log4j2 version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt Updates kotlin-semver library version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt Updates KotlinPoet version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt Updates embedded/runtime Kotlin version constants and JetBrains annotations version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/JetBrainsAnnotations.kt Updates JetBrains annotations version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaDiffUtils.kt Updates java-diff-utils version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt Updates Jackson BOM version and annotations version constants.
buildSrc/src/main/kotlin/io/spine/dependency/lib/J2ObjC.kt Updates J2ObjC annotations version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/HttpClient.kt Updates google-http-client version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt Updates Guava version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt Updates Gson version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt Updates gRPC Kotlin stub version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt Updates gRPC BOM version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Flogger.kt Updates Flogger version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Firebase.kt Updates Firebase Admin SDK version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsLogging.kt Updates Commons Logging version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCodec.kt Updates Commons Codec version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCli.kt Updates Commons CLI version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Clikt.kt Updates Clikt version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt Updates Caffeine version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Auto.kt Updates AutoValue version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Asm.kt Updates ASM version constant.
buildSrc/src/main/kotlin/io/spine/dependency/lib/Aedile.kt Updates Aedile version constant.
buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt Updates copyright year header only.
buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt Updates kotlinx-datetime version constant.
buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt Updates copyright year header only.
buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt Updates copyright year header only.
buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt Updates PMD version constant.
buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt Updates Gradle Plugin Publish Plugin version constant.
buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt Updates KSP plugin version constant.
buildSrc/src/main/kotlin/io/spine/dependency/build/GradleDoctor.kt Updates Gradle Doctor plugin version constant.
buildSrc/src/main/kotlin/io/spine/dependency/build/ErrorProne.kt Updates gradle-errorprone plugin version constant.
buildSrc/src/main/kotlin/io/spine/dependency/build/CheckerFramework.kt Updates Checker Framework version constant.
buildSrc/src/main/kotlin/io/spine/dependency/build/AnimalSniffer.kt Updates Animal Sniffer annotations version constant.
buildSrc/build.gradle.kts Aligns embedded Kotlin/Guava/ErrorProne/Protobuf plugin versions used by buildSrc.

Comment thread plugin-testlib/src/main/kotlin/io/spine/tools/gradle/testing/TestKitCoverage.kt Outdated
alexander-yevsyukov and others added 2 commits June 6, 2026 23:35
Dokka in this repo documents only Public/Protected visibilities
(buildSrc/.../DokkaExts.kt), so the consumer-facing instructions placed on
the internal `enableTestKitCoverage` extension never reached the published
HTML/Javadoc. Move the "Enabling TestKit coverage" section and the
copy-paste Gradle recipe onto the public GradleProject class KDoc (which
also covers runGradleBuild), and leave a maintainer-facing pointer on the
internal function.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add and extend unit tests across jvm-tools, plugin-base, psi-java, psi,
plugin-testlib, and protobuf-setup-plugins, raising total line coverage
from ~80% to 95.5%.

Notable: `ResourceDirectorySpec` had a backtick top-level class name with
spaces that Gradle's test detector silently skipped, so the suite never
ran; renamed it to a valid identifier with `@DisplayName`.

Tests only; no production code changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 98 out of 99 changed files in this pull request and generated 2 comments.

Address PR #175 review: `SourceSet.findProtoDirectorySet()` used
`extensions.getByName(...)`, which throws when the `proto` extension is
absent, so it could never return `null` as its KDoc documents and the
`?: return false` fallback in `containsProtoFiles()` was unreachable.
Switch to `findByName(...) as? SourceDirectorySet`.

Also fix the misleading `SourceSetExtsSpec` test name (it applied the
plugin and asserted non-null) and add cases for the plugin-not-applied
path now that it is reachable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alexander-yevsyukov

Copy link
Copy Markdown
Contributor Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 99 out of 100 changed files in this pull request and generated 1 comment.

alexander-yevsyukov and others added 2 commits June 7, 2026 02:39
The TestKit worker can keep a `.gradle/.../kotlin-dsl-plugin-entries.lock`
file locked after the build on Windows, so JUnit's `@TempDir` strict
deletion threw a `DeletionException` and failed the otherwise-passing test
("Build on Windows" check). Replace `@TempDir` with a manual temp directory
and a best-effort `deleteRecursively()` teardown that silently skips files
it cannot delete.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address PR #175 review: the "all known protoc plugins" assertion used
`shouldContainExactly`, coupling the test to the enum declaration order.
Switch to `shouldContainExactlyInAnyOrder` — it still verifies all names
are present with their exact lower-camel-case spelling and that there are
no extras, without breaking on a future reordering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alexander-yevsyukov

Copy link
Copy Markdown
Contributor Author

@codex review

Replace the manual temp-dir + best-effort teardown with JUnit's `@TempDir`
injected as a parameter on each test function, giving every test its own
fresh project directory. Revisits the Windows `@TempDir` cleanup failure
with a simpler form; CI on Windows will confirm whether it suffices.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 100 out of 101 changed files in this pull request and generated no new comments.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28bd39c3ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The `@TempDir`-parameter form still failed the "Build on Windows" check
with the same `DeletionException` on a locked
`kotlin-dsl-plugin-entries.lock` (JUnit uses strict deletion for both the
field and parameter forms). Revert to a manual temp directory with a
best-effort `deleteRecursively()` teardown, which ignores files the
Windows TestKit worker keeps locked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alexander-yevsyukov alexander-yevsyukov changed the title Document TestKit coverage for external consumers; refresh dependencies via config Document TestKit coverage for external consumers Jun 7, 2026
@alexander-yevsyukov alexander-yevsyukov changed the title Document TestKit coverage for external consumers Document TestKit coverage for external consumers, raise coverage Jun 7, 2026

@armiol armiol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alexander-yevsyukov LGTM with a comment for the future PRs.

fun `load from a JAR for a class packaged in it`() {
// Guava is a binary dependency on the test classpath, so its classes
// are loaded via a `JarURLConnection`.
val cls = com.google.common.base.Preconditions::class.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given we would like to eventually strip Guava, I would task the agent to find something else for this test.

@alexander-yevsyukov
alexander-yevsyukov merged commit f80a009 into master Jun 7, 2026
8 checks passed
@alexander-yevsyukov
alexander-yevsyukov deleted the update-config-and-testkit-coverage branch June 7, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants