Skip to content

symfony/symfony

6.2
Switch branches/tags
Code

Latest commit

…hanged on fast computers (PhilETaylor)

This PR was merged into the 6.2 branch.

Discussion
----------

[Clock] sleep in test, 1millisecond to ensure time has changed on fast computers

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

So... Im "one of those" people that bought a Mac Studio Mac with a Apple M1 Ultra CPU and 128Gb RAM

When running the unit tests for the new Clock Component there is a test that compares before and after with

```php
$before = new \DateTimeImmutable();
$clock = new MockClock();
$after = new \DateTimeImmutable();
```

**50% of the tuns the unit tests fail**, when run on this blazingly fast Mac, fail with message:

<img width="1041" alt="Screen Shot 2022-09-03 at 01 28 01" src="https://user-images.githubusercontent.com/400092/188248812-80ca31f3-3b54-4b5b-a44f-5346f85fa3a8.png">

As you can see the timestamps are exactly the same.

Adding a one millionth of  second delay ensures that on blazingly fast computers (And I DO UNDERSTAND that GitHub action runners/AppVeyor is never going be fast haha) that the tests pass 100% of the time instead of giving false failures.

I appreciate this might be an edge case but computers are only getting faster :) and one day a Mac like this might not cost £6000!

Commits
-------

4a16953 sleep 1millisecond to ensure time has changed on fast computers
07d4940

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

Symfony is a PHP framework for web and console applications and a set of reusable PHP components. Symfony is used by thousands of web applications and most of the popular PHP projects.

Installation

Sponsor

Symfony 6.2 is backed by Les-Tilleuls.coop and Sulu.

Les-Tilleuls.coop is a team of 50+ Symfony experts who can help you design, develop and fix your projects. We provide a wide range of professional services including development, consulting, coaching, training and audits. We also are highly skilled in JS, Go and DevOps. We are a worker cooperative!

Sulu is the CMS for Symfony developers. It provides pre-built content-management features while giving developers the freedom to build, deploy, and maintain custom solutions using full-stack Symfony. Sulu is ideal for creating complex websites, integrating external tools, and building custom-built solutions.

Help Symfony by sponsoring its development!

Documentation

Community

Contributing

Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.

Security Issues

If you discover a security vulnerability within Symfony, please follow our disclosure procedure.

About Us

Symfony development is led by the Symfony Core Team and supported by Symfony contributors.