Skip to content

please-style: choose a shared-helper location for Kotlin Multiplatform modules #49

Open

Description

@amondnet

Follow-up from #45 (PR #48)

PR #48 taught please-style check to recognize Kotlin Multiplatform modules. The test-helpers-in-dedicated-location check now skips them, because the only helper location it knows for Kotlin/Java is Gradle's src/testFixtures/, and multiplatform modules have no such source set (java-test-fixtures does not apply to KMP source sets).

Without a skip, the check would tell a multiplatform module to move a shared helper (for example a public FakeClock in src/commonTest/kotlin/…, imported by two other tests) to src/testFixtures/, a finding nobody can fix. So shared helpers in multiplatform modules are not checked at all right now.

Current behavior

  • packages/cli/src/check/layouts.ts: jvmLayout returns no helper dirs for a multiplatform unit (helperDirs: unit => unit.multiplatform === true ? [] : ['src/testFixtures']).
  • packages/cli/src/check/check-helpers.ts: inspectHelpers skips a candidate whose unit has no helper dirs.
  • Both READMEs (packages/cli/README.md, README.ko.md) say the helper check skips multiplatform modules.

Decide

Choose where shared test helpers live in a Kotlin Multiplatform module, then enforce it. Candidates:

  1. A package inside commonTest, for example src/commonTest/kotlin/**/testing/. Works with no extra Gradle setup, but a helper is visible only to the module's own tests.
  2. A dedicated test-support module, for example :<module>-testing with its helpers in commonMain. Other modules can share it, but the checker would have to tie that module to its consumers.
  3. A custom source set such as commonTestFixtures, wired with dependsOn. Closest to src/testFixtures, but it is not a Gradle or Kotlin convention, so each project has to configure it by hand.

The choice probably belongs in ADR-0022 (engineering-standards) next to the existing src/testFixtures/ rule for Kotlin/Java.

Done when

  • A location is chosen and recorded in the standard.
  • jvmLayout returns that location as the helper dir for multiplatform units, so the check runs for them again.
  • Tests cover a helper outside the location (reported, with the right suggested dir) and inside it (not reported), in commonTest and in a target set such as jvmTest.
  • Both READMEs describe the multiplatform helper location instead of the skip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions