[dx] Set Option::SOURCE parameter from the resolved paths - #8424
Open
SanderMuller wants to merge 1 commit into
Open
[dx] Set Option::SOURCE parameter from the resolved paths#8424SanderMuller wants to merge 1 commit into
SanderMuller wants to merge 1 commit into
Conversation
AbstractRectorTestCase sets it, a real run never does, so code reading the parameter works under the test harness and is empty in production. Excluded from the cache invalidation hash: the paths change per invocation, so hashing them would drop the cache whenever the target changes.
Comment on lines
+57
to
+71
| try { | ||
| SimpleParameterProvider::setParameter(Option::PATHS, [__DIR__ . '/config']); | ||
|
|
||
| $this->make(ConfigurationFactory::class) | ||
| ->createFromInput($this->createInput([__DIR__ . '/Source'])); | ||
|
|
||
| $this->assertSame( | ||
| [__DIR__ . '/Source'], | ||
| SimpleParameterProvider::provideArrayParameter(Option::SOURCE) | ||
| ); | ||
| } finally { | ||
| SimpleParameterProvider::setParameter(Option::PATHS, $originalPaths); | ||
| SimpleParameterProvider::setParameter(Option::SOURCE, $originalSource); | ||
| SimpleParameterProvider::setParameter(Option::IS_RUN_NARROWED, $originalIsRunNarrowed); | ||
| } |
Member
There was a problem hiding this comment.
Please try a more straighfoward way of testing. try/finally hides the intent
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.
Option::SOURCEis only written toSimpleParameterProviderbyAbstractRectorTestCase. A real run leaves it empty, so an extension reading the processed paths from the parameter works under the test harness and gets[]in production.I hit this in a rules package that reads
Option::PATHSand falls back toOption::SOURCEto learn which paths a run covers. The fallback works in its tests and never fires in a real run.ConfigurationFactory::resolvePaths()now sets it to the paths it resolved: the command line when given,Option::PATHSotherwise. It already setsIS_RUN_NARROWEDandFILES_WITHOUT_EXTENSIONthere.Option::SOURCEis also inCACHE_IGNORED_PARAMETER_NAMES: the resolved paths change per invocation, so hashing them would drop the cache whenever the target changes.