Skip to content

[TwigComponent] Fix the flaky render time assertion of the data collector test - #4108

Merged
Kocal merged 1 commit into
symfony:3.xfrom
Kocal:fix/twig-component-flaky-render-time-test
Oct 15, 2026
Merged

Kocal merged 1 commit into
symfony:3.xfrom
Kocal:fix/twig-component-flaky-render-time-test

Conversation

@Kocal

@Kocal Kocal commented Oct 15, 2026

Copy link
Copy Markdown
Member
Q A
Bug fix? no
New feature? no
Deprecations? no
Documentation? no
Issues
License MIT

TwigComponentDataCollectorTest::testLateCollectWithCollectedData() expects a positive render time between a PreRenderEvent and a PostRenderEvent logged back to back. Both events get their time from microtime(true), which often returns the same value for two calls that close.

Repeating the sequence of the test 10,000 times gives a render time of 0.0 in 7,472 runs.

The test now waits 1 µs between the two events, and the same 10,000 runs never give 0.0. The failure showed up at random in the TwigComponent suite while working on #4107, in 4 of 6 full runs.

…ctor test

| Q              | A
| -------------- | ---
| Bug fix?       | no
| New feature?   | no
| Deprecations?  | no
| Documentation? | no
| Issues         |
| License        | MIT

`TwigComponentDataCollectorTest::testLateCollectWithCollectedData()` expects a positive render time between a `PreRenderEvent` and a `PostRenderEvent` logged back to back. Both events get their time from `microtime(true)`, which often returns the same value for two calls that close.

Repeating the sequence of the test 10,000 times gives a render time of `0.0` in 7,472 runs.

The test now waits 1 µs between the two events, and the same 10,000 runs never give `0.0`. The failure showed up at random in the TwigComponent suite while working on symfony#4107, in 4 of 6 full runs.
@Kocal Kocal self-assigned this Oct 15, 2026
@Kocal
Kocal merged commit 9ed9a91 into symfony:3.x Oct 15, 2026
42 of 43 checks passed
@Kocal
Kocal deleted the fix/twig-component-flaky-render-time-test branch October 15, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants