Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 30, 2025

Pull Request

Description

What does this PR do?

Fixes flaky delay-related tests on Windows CI. The tests were failing intermittently because Windows timer resolution can cause microtime() to report slightly less than the expected delay (e.g., 49.997ms instead of 50ms, or 9.38ms instead of 10ms).

Failed asserting that 49.99709129333496 is equal to 50 or is greater than 50.
Failed asserting that 9.380102157592773 is equal to 10 or is greater than 10.

Fixes https://github.com/Thavarshan/fetch-php/actions/runs/19784949325/job/56698436697

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

Changes Made

  • Added 2ms tolerance to timing assertion in test_fake_with_delay (MockingIntegrationTest.php)
  • Added 2ms tolerance to timing assertion in test_executes_response_with_delay (MockResponseTest.php)
// MockingIntegrationTest.php - Before
$this->assertGreaterThanOrEqual(50, $duration);

// MockingIntegrationTest.php - After
$this->assertGreaterThanOrEqual(48, $duration);

// MockResponseTest.php - Before
$this->assertGreaterThanOrEqual(10, $duration);

// MockResponseTest.php - After
$this->assertGreaterThanOrEqual(8, $duration);

Testing

How has this been tested?

  • All existing tests pass

Test Environment:

  • PHP Version: 8.3, 8.4
  • Operating System: Windows, Ubuntu, macOS (CI matrix)

Documentation

  • Code is self-documenting with clear variable names and logic
  • PHPDoc comments added for public methods

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • New and existing unit tests pass locally with my changes

Additional Notes

Windows has lower timer resolution than Linux/macOS. A 2ms tolerance is sufficient to account for this while still validating the delay mechanism works correctly. Reviewed all other timing-related tests in the codebase - only tests that measure actual elapsed time against an expected delay were affected. Other tests (ManagesRetriesTest, ConnectionPoolTest, CacheTest) check calculated values or timestamps rather than elapsed durations, so they don't need the same fix.

Original prompt

Please fix this failing CI test:

https://github.com/Thavarshan/fetch-php/actions/runs/19784949325/job/56698436697#step:7:1


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@netlify
Copy link

netlify bot commented Nov 30, 2025

Deploy Preview for fetch-php canceled.

Name Link
🔨 Latest commit d8b00bd
🔍 Latest deploy log https://app.netlify.com/projects/fetch-php/deploys/692bbeff6974e2000836f273

Co-authored-by: Thavarshan <10804999+Thavarshan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing CI test in fetch-php Fix timing precision issue in test_fake_with_delay on Windows Nov 30, 2025
Copilot AI requested a review from Thavarshan November 30, 2025 02:21
@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@Thavarshan
Copy link
Owner

@copilot please check and fix this failing CI test as well.

Please address all similar tests in other areas of the codebase.

Co-authored-by: Thavarshan <10804999+Thavarshan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 30, 2025

@copilot please check and fix this failing CI test as well.

Please address all similar tests in other areas of the codebase.

Fixed the failing test test_executes_response_with_delay in MockResponseTest.php (d8b00bd). Reviewed all similar timing tests in the codebase - only tests that measure actual elapsed time against an expected delay were affected. The other tests (ManagesRetriesTest, ConnectionPoolTest, CacheTest) check calculated values or timestamps rather than elapsed durations, so they don't need the same fix.

Copilot AI changed the title Fix timing precision issue in test_fake_with_delay on Windows Fix timing precision issues in delay tests on Windows Nov 30, 2025
@Thavarshan Thavarshan marked this pull request as ready for review November 30, 2025 04:04
@Thavarshan Thavarshan merged commit baf90dd into main Nov 30, 2025
34 checks passed
@Thavarshan Thavarshan deleted the copilot/fix-failing-ci-test branch November 30, 2025 04:04
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.

2 participants