Update the Rector integration test to a newer commit - #15156
Update the Rector integration test to a newer commit#15156SanderMuller wants to merge 4 commits into
Conversation
|
CI has answered the caveat in the description, and not in my favour, so here is where this stands. The bump does remove the two rule-level failures: Those three shell out to What I can rule out:
What is left is the phar swap. Rector's CI runs against a composer-installed phpstan, whereas this job copies Happy to close this if you would rather not carry a partial fix, or leave it open as the first half if you think the console-output difference is worth a look on our side. I did not want to leave the description claiming this greens the job when it does not. |
|
seems related to rectorphp/rector-downgrade-php#394 |
|
Confirmed, and it explains the other job rather than this one. The downgrade job's single failure is I replayed both downgrade jobs at It does not help the three |
does this mean these tests are also red on the rector repo itself? |
|
No, they are green there, and chasing that turned up that my phar explanation above was wrong. On I then replayed our job locally: rector-src at Reading the CI failures properly also changes what they are. All three expectations get
The cheapest way to get the cause is a diagnostic in the job: run |
Does this mean rector-src should be fixed to get more meaningful debug info? |
|
Yes, and it is a small one. $this->assertSame($expectedOutput, preg_replace('/ +/', ' ', $process->getOutput()), sprintf(
'exit code %d, stderr: %s',
(int) $process->getExitCode(),
$process->getErrorOutput()
));I tried it against a deliberately wrong expectation, and the failure gains one line above the diff: Happy to send it to rector-src. It is worth as much to them as to us, since any failure of a spawned process in that test currently reports as an empty string with no reason attached. |
yes, thats what I had in mind. |
|
Sent: rectorphp/rector-src#8440. One detail I changed from the snippet above: |
Both Rector jobs have been failing since 2.2.10. The pinned b14e0ab4 is from 2026-08-05 and predates Rector's adaptation to the node callback ordering that changed in that release: rectorphp/rector-src#8420, "Support PHPStan 2.2.10 scope changes", landed 2026-08-30 and updated CallCollectionAnalyzer and PHPStanNodeScopeResolver. Bumping the pin past that commit and refreshing rector-composer.lock against it, generated with PHP 8.4 since that is what the jobs run. Verified by replaying the job from the committed lock: the two rule tests that were failing, RemoveUnusedPrivateMethodRector and SimplifyEmptyCheckOnEmptyArrayRector, are OK (63 tests, 66 assertions). Only the rector-src pin is touched here. The separate rector-downgrade-php job has its own pin and its own failure, which I have not looked into. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
3d21c49 to
9edd131
Compare
|
@SanderMuller one rector test still fails. might need another update? |
rectorphp/rector-src#8440 landed on 2026-09-04 and makes the tests/Bin assertion carry the spawned process's exit code and stderr. The previous pin predates it, so the three failures report only an empty string with no reason attached. 63a2f160d is rector-src main HEAD; its own PHP 8.4 and 8.5 ubuntu test jobs are green. rector-composer.lock regenerated against it on PHP 8.4, the version the jobs run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Yes, and the update to make is the pin, so that the failure finally says why. The three Bumped both pin sites to Replayed the job at the new pin, with the phar,
I still cannot reproduce the CI failure locally, and there is one hypothesis I cannot rule out. My One note for anyone replaying the analyse half: it reports 11 errors on PHP 8.5 and 0 on 8.4. I nearly wrote up "the bump breaks the analyse job" before checking on the version the job actually uses. |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Green now, and the earlier bump is what made it findable. The job stopped printing three empty strings and
I isolated it to a single
The other twoThey were a separate bug: The leak came from a test I added in rectorphp/rector-src#8424, which is inside this pin range. I had a fix With both commits, and a One note for anyone who reproduces this: delete |
| # vendor/, so both preload files load. They declare the same | ||
| # isPHPStanTestPreloaded() function, so the second one is a fatal error and | ||
| # every spawned bin/rector call writes nothing. | ||
| rm preload-split-package.php |
There was a problem hiding this comment.
What changed in phpstan (or in rector) that we need this quirk now?
There was a problem hiding this comment.
Nothing changed in PHPStan. Rector gained its first test that runs bin/rector as a subprocess, and that
is what exposed a fatal error which was already there.
The two preconditions are old:
- 2023-04-27, [Preload] Add preload-split-package.php to bin/rector.php to fix overlap php-doc-parser rectorphp/rector-src#3692 added the
preload-split-package.phpblock tobin/rector.php,
with theis_dir(__DIR__ . '/../../../../vendor')probe. - 2025-10-07, [autoload] Add workaround for phpstan + rector tests co-run to avoid duplicated php-parser loading error rectorphp/rector-src#7440 put the same
isPHPStanTestPreloaded()function in both
preload.phpandpreload-split-package.php. From then on, loading both files was always fatal.
Nothing in the suite ever executed bin/rector.php, so the fatal had no way to fire. At the old pin
b14e0ab42 the only bin/rector mention under tests/ is a string in an argv array, in
AutoloadFileParameterResolverTest, which spawns nothing.
Then rectorphp/rector-src#8287 added tests/Bin/RectorTest.php, which does
Process::fromShellCommandline(PHP_BINARY . ' bin/rector ...'). That commit is not in b14e0ab42 and is
in the pin this PR moves to, so the bump is what made it visible.
I checked each of those against the pinned trees rather than the dates alone.
If you would rather not carry the quirk
Two alternatives, and I am happy to switch:
- Clone this one project one directory deeper, so the four-levels-up probe lands on
e2e/instead of the
repository root. No per-project file removal, but the Rector job stops sharing thee2e/integration/repo
path with the other jobs. - Fix the probe upstream. It infers "installed at
vendor/rector/rector" from a directory four levels up,
which is true for any checkout three levels below something that has avendor/. I contribute there and
can raise it.
The quirk is the smallest change of the three, which is why I sent it first.
Integration - Rector tests and Integration - Rector downgrade PHP tests both pass on d5a751a. The two
red checks left are Larastan and phpstan-laravel, which are red on phpstan-src PRs too.
There was a problem hiding this comment.
Fix the probe upstream. It infers "installed at vendor/rector/rector" from a directory four levels up,
which is true for any checkout three levels below something that has a vendor/. I contribute there and
can raise it.
We should at least raise a issue and ask them whether this assumption exists on purpose or by mistake
There was a problem hiding this comment.
Sent a PR instead, since Rector takes those faster than issues: rectorphp/rector-src#8478.
It is 2 lines of production code. The two preload conditions in bin/rector.php describe alternative
layouts, but they are separate if statements. So a checkout that matches both loads both files, and the
shared isPHPStanTestPreloaded() is then fatal. elseif says what they already mean.
To answer your question directly: the depth test is not the whole story. The first condition is "I have my
own vendor/" and the second is "I sit inside a project's vendor/". Neither is wrong on its own, and I
installed rector/rector-src as a dependency to confirm both intended layouts still work. What is missing
is that they exclude each other.
The PR carries a red/green test that builds the overlapping layout from the real bin/rector.php and both
real preload files, and it links back here.
If they take it, we can drop the rm from this workflow and just move the pin again.
Both Rector jobs (
Integration - Rector testsand, separately, the downgrade one) have been red on every phpstan-src pull request since 2.2.10. Forrector-srcthe cause is just a stale pin.The node callback ordering changed in 2.2.10 (
ae03ab3ec, part of phpstan/phpstan-src#6248). Rector attaches scopes to nodes as callbacks arrive and reads them back later, so it needed updating, which it got in rectorphp/rector-src#8420, "Support PHPStan 2.2.10 scope changes", landed 2026-08-30. It touchesCallCollectionAnalyzerandPHPStanNodeScopeResolver.The pin here is
b14e0ab4from 2026-08-05, three and a half weeks before that fix, so the job has been testing a Rector that could not pass.The change
rector-srcref at both call sites toc8f5daefe2e/integration/rector-composer.lockagainst it, generated with PHP 8.4 since that is what the jobs runVerified
Replayed the job from the committed lock at the new ref. The two rule tests that were failing in CI now pass:
The full suite locally leaves three
Tests\Bin\RectorTest::testConsoleOutputfailures, but those shell out tobin/rectorand compare its console output, and the expectation data in my run contains my own PHP binary path. Rector's own CI is green on this exact commit today, including itsTestsworkflow, so I am fairly confident they pass in a normal environment. Your CI will settle it either way.Scope
Only the
rector-srcpin.rector-downgrade-phpis a separate repository with its own pin and its own single failure, which I have not diagnosed, so I left it alone.Context: #15155, where you pointed out that callback order was never promised and this belonged on the Rector side. Agreed, and it turned out they had already done it.