fix(fixt): system properties override env vars for TEST_RESOURCES_FOLDER#26
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixt.getTestResourcesLocation()iteratedSystem.getProperties()first, thenSystem.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 agorapulsejava-common-configurationplugin does on every test task), an in-testSystem.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 viaSystem.setProperty.Test plan
./gradlew :fixt:testpasses locally on Gradle 9.5 / Java 25 / Groovy 5 / Spock 2.4-groovy-5.01.0.0.RC5(or whatever version comes next) so downstream consumers can bump🤖 Generated with Claude Code