Skip to content

Recognize Gradle tasks as checks in the done gate - #59

Open
McCal-Codes wants to merge 1 commit into
codenotary:mainfrom
McCal-Codes:gradle-checks
Open

McCal-Codes wants to merge 1 commit into
codenotary:mainfrom
McCal-Codes:gradle-checks

Conversation

@McCal-Codes

Copy link
Copy Markdown

The done gate only knows a bare gradlew test. Android and Kotlin projects usually run tasks with a project path, so ./gradlew :app:testDebugUnitTest, ./gradlew :app:assembleDebug, ./gradlew :app:lintDebug and anything through .\gradlew.bat record no check at all. Two things follow:

  • A failing Gradle test or build never reaches the gate.
  • After an edit, an answer that says the tests pass is sent back, because no test of that kind was seen.

This adds a GRADLE prefix to the check patterns in hooks/format.ts. It accepts ./gradlew, .\gradlew.bat or gradle, then any flags and earlier tasks, then a task with an optional project path:

Kind Gradle tasks
test test, test…UnitTest, connected…AndroidTest, check
build assemble…, bundle…, build
lint lint…, ktlintCheck, detekt, spotlessCheck
typecheck compile…Kotlin
  • A task named right after -x or --exclude-task is skipped, so ./gradlew :app:assembleDebug -x test is a build, not a test.
  • testClasses, buildEnvironment, clean and --stop stay unrecognized.
  • With several tasks in one call, the existing order (typecheck, lint, test, build) decides, so assembleDebug testDebugUnitTest reads as a test.

docs/guide.md gets one paragraph, and tests/format.test.ts gets one test with 18 cases.

Testing

  • New test findCheck reads Gradle tasks with a project path, flags and the Windows wrapper: passes.
  • claude plugin test . on Windows 11 (Claude Code 2.1.332): 298 pass, 64 fail. The same 64 tests fail on an unpatched 0.60.0 checkout, so none are caused by this change. They look like Windows path issues in the tests. For example, the spool tests expect /spool/sess-1.json and get undefined, and a web test expects --open and gets the port. That may be useful, since the README asks for Windows reports.
  • Outside the suite, a 35-case check of findChecks passed: real Android commands, the -x cases, commands that look like checks but aren't (echo "./gradlew test", grep gradlew build.gradle), and the existing npm, cargo, tsc and make patterns.

tsc --noEmit was not run, because it needs the generated .claude-plugin/types.

The done gate only knew a bare \gradlew test\, so Android and Kotlin projects that run \./gradlew :app:testDebugUnitTest\, \:app:assembleDebug\ or \.\gradlew.bat\ recorded no checks: failures went unseen, and an answer saying the tests pass was sent back. Gradle tasks with a project path, flags and the Windows wrapper now count as tests, builds, lint and typecheck; a task after -x is left out.

@vchaindz vchaindz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this, the bare gradlew test pattern was a real hole for Android projects. The approach fits how CHECKS already works. Three cases don't come out right yet, all in the GRADLE prefix:

1. A task after -x is never reached

./gradlew -x lint build          -> no check
./gradlew -x test assembleDebug  -> no check

The lookahead stops the token skip at -x, so everything after it is lost, not only the excluded task. Skipping the flag together with its value fixes it.

2. Root-project tasks with a leading colon

./gradlew :test, :build and :check match nothing, because (?::?[\w.-]+:)* wants a colon after every segment. :?(?:[\w.-]+:)* covers them.

3. Hyphenated project names read as tasks

./gradlew test-utils:assemble   -> test   (is a build)
./gradlew lint-rules:assemble   -> lint   (is a build)

\b matches before the hyphen. This one matters most: a wrong "test" lets an answer that says the tests pass through the gate. Ending the task on (?=\s|$) fixes it.

This prefix passes your 18 cases plus the ones above, with (?=\s|$) after each Gradle task group in place of the shared \b:

const GRADLE = String.raw`(?:\S*\\)?(?:gradlew(?:\.bat)?|gradle)\s+(?:(?:-x|--exclude-task)(?:\s+|=)\S+\s+|(?!-x\s|--exclude-task[\s=])\S+\s+)*?:?(?:[\w.-]+:)*`

Please add those cases to the test.

Smaller things:

  • ./gradlew tasks --group build and ./gradlew help --task test still read as build and test, since a flag's value looks like a task. Fine to leave, but then it wants a // shortcut: comment naming the limit.
  • The comment above GRADLE is two lines; we keep them to one.
  • The 64 Windows failures deserve their own issue, could you open one with the output?

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.

2 participants