John Erling Blad has submitted this change and it was merged.

Change subject: Fix clock ticks in test
......................................................................


Fix clock ticks in test

If the time is picked up several different places and compared
there can be a "race condition" where the clock ticks and the
tests fails because the time isn't equal anymore. This fixes
one such case.

Change-Id: I11e08591f24404825df22d2613db4b407e75803b
---
M lib/tests/phpunit/changes/ChangeRowTest.php
1 file changed, 5 insertions(+), 3 deletions(-)

Approvals:
  John Erling Blad: Verified; Looks good to me, approved



diff --git a/lib/tests/phpunit/changes/ChangeRowTest.php 
b/lib/tests/phpunit/changes/ChangeRowTest.php
index 17edf91..8db9111 100644
--- a/lib/tests/phpunit/changes/ChangeRowTest.php
+++ b/lib/tests/phpunit/changes/ChangeRowTest.php
@@ -152,9 +152,11 @@
         * @dataProvider instanceProvider
         */
        public function testGetAge( $changeRow ) {
-               $this->assertEquals(
-                       time() - (int)wfTimestamp( TS_UNIX, '20130101000000' ),
-                       $changeRow->getAge()
+               // Don't assert on equalness because all previous code takes 
time!
+               $this->assertTrue(
+                       // the time used is one above the minimum run time (4s) 
for the test,
+                       // still the normal difference to observe would be 1s.
+                       abs( ( time() - (int)wfTimestamp( TS_UNIX, 
'20130101000000' ) ) - $changeRow->getAge() ) <= 5
                );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/56152
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I11e08591f24404825df22d2613db4b407e75803b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: John Erling Blad <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: John Erling Blad <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to