Skip to content

GROOVY-12236: Allow @ASTTest to be disabled via a groovy.asttest.enab… - #2769

Open
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12236
Open

GROOVY-12236: Allow @ASTTest to be disabled via a groovy.asttest.enab…#2769
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12236

Conversation

@paulk-asert

Copy link
Copy Markdown
Contributor

…le system property

The @asttest closure is evaluated during compilation, so merely compiling source which carries the annotation executes that code, whether or not the compiled result is subsequently run. Embedders which compile source they do not control have no way to turn this off.

Add a groovy.asttest.enable system property, defaulting to true, which makes the annotation a no-op when set to false. This mirrors groovy.grape.enable for @grab. The check is in visit(), so the closure is never scheduled onto a compilation phase rather than being scheduled and skipped.

The property is read per-visit rather than into a static final field so that it can be exercised without relying on JVM startup state. Being a system property it is process-wide, exactly as groovy.grape.enable is: a JVM cannot enable @asttest for one compilation and disable it for another.

…le system property

The @asttest closure is evaluated during compilation, so merely compiling
source which carries the annotation executes that code, whether or not the
compiled result is subsequently run. Embedders which compile source they do
not control have no way to turn this off.

Add a groovy.asttest.enable system property, defaulting to true, which makes
the annotation a no-op when set to false. This mirrors groovy.grape.enable
for @grab. The check is in visit(), so the closure is never scheduled onto a
compilation phase rather than being scheduled and skipped.

The property is read per-visit rather than into a static final field so that
it can be exercised without relying on JVM startup state. Being a system
property it is process-wide, exactly as groovy.grape.enable is: a JVM cannot
enable @asttest for one compilation and disable it for another.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.9818%. Comparing base (2f85f42) to head (18109b3).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...haus/groovy/transform/ASTTestTransformation.groovy 0.0000% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2769        +/-   ##
==================================================
- Coverage     69.9869%   69.9818%   -0.0051%     
+ Complexity      35529      35527         -2     
==================================================
  Files            1557       1557                
  Lines          131686     131687         +1     
  Branches        24174      24174                
==================================================
- Hits            92163      92157         -6     
- Misses          31189      31193         +4     
- Partials         8334       8337         +3     
Files with missing lines Coverage Δ
...haus/groovy/transform/ASTTestTransformation.groovy 84.2857% <0.0000%> (-1.2215%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 18109b3
▶️ Tests: 101334 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

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