Skip to content

fix(fixt): system properties override env vars for TEST_RESOURCES_FOLDER#26

Merged
musketyr merged 1 commit into
masterfrom
fix/sysprops-take-precedence-over-env
May 23, 2026
Merged

fix(fixt): system properties override env vars for TEST_RESOURCES_FOLDER#26
musketyr merged 1 commit into
masterfrom
fix/sysprops-take-precedence-over-env

Conversation

@musketyr
Copy link
Copy Markdown
Collaborator

Summary

Fixt.getTestResourcesLocation() iterated System.getProperties() first, then System.getenv(), with every match overwriting the previous result. That made env vars win — which is the wrong precedence.

When a Gradle build sets test.environment('TEST_RESOURCES_FOLDER', '<projectDir>/src/test/resources') (which the agorapulse java-common-configuration plugin does on every test task), an in-test System.setProperty('TEST_RESOURCES_FOLDER', tmp.path) — the standard way to redirect fixt writes to a JUnit/Spock @TempDir — gets silently ignored.

Swap the iteration order so env runs first and system properties run second. Now System.setProperty (the canonical JVM-level override) takes precedence, while the build-time env var remains the baseline tests inherit by default.

This unblocks gru's TextMinionSpec / JsonMinionSpec "fixture file is created" tests, which redirect writes via System.setProperty.

Test plan

  • ./gradlew :fixt:test passes locally on Gradle 9.5 / Java 25 / Groovy 5 / Spock 2.4-groovy-5.0
  • After merge, cut 1.0.0.RC5 (or whatever version comes next) so downstream consumers can bump

🤖 Generated with Claude Code

getTestResourcesLocation() iterated System.getProperties() first, then
System.getenv(), with every match overwriting the previous result.
That made env vars win, which is the wrong precedence: a test that
calls System.setProperty('TEST_RESOURCES_FOLDER', tmp.path) to
redirect fixt writes to a JUnit/Spock @tempdir gets silently
ignored because Gradle's `test.environment('TEST_RESOURCES_FOLDER',
'<projectDir>/src/test/resources')` (set by the agorapulse
java-common-configuration plugin) overrides it.

Swap the iteration order so the env loop runs first and the system
properties loop runs second. Now System.setProperty - the canonical
JVM-level override - takes precedence, while the build-time env var
remains the baseline that tests inherit by default.

This unblocks gru's TextMinionSpec / JsonMinionSpec "fixture file is
created" tests, which redirect writes to a `@TempDir File tmp` via
System.setProperty.
@musketyr musketyr merged commit 50575f5 into master May 23, 2026
2 checks passed
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.

1 participant