WordPoints / wordpoints

Points plugin for WordPress
GNU General Public License v2.0
20 stars 15 forks source link

Some periods hook extension PHPUnit tests randomly failing #481

Closed JDGrimes closed 7 years ago

JDGrimes commented 8 years ago

See this build:

There was 1 failure:

1) WordPoints_Points_Hook_Extension_Legacy_Periods_Test::test_should_hit_period_over_points_positive_offset with data set "absolute" (false)
Failed asserting that actual size 0 matches expected size 1.

/home/travis/build/WordPoints/wordpoints/tests/phpunit/tests/classes/hook/extension/periods.php:435
/home/travis/build/WordPoints/wordpoints/tests/phpunit/tests/points/classes/hook/extension/legacy/periods.php:217
/home/travis/build/WordPoints/wordpoints/tests/phpunit/tests/points/classes/hook/extension/legacy/periods.php:236

This is probably related to time calculations in the tests sometimes not being quite right for some reason.

JDGrimes commented 8 years ago

Another example:

There was 1 failure:

1) WordPoints_Hook_Extension_Periods_Test::test_should_hit_absolute_gmt_offset with data set "+0" (0)
Failed asserting that actual size 1 matches expected size 2.

/home/travis/build/WordPoints/wordpoints/tests/phpunit/tests/classes/hook/extension/periods.php:742
JDGrimes commented 8 years ago

Also:

There was 1 failure:

1) WordPoints_Hook_Extension_Periods_Test::test_should_hit_absolute_gmt_offset with data set #-5 (-5)
Failed asserting that actual size 1 matches expected size 2.

/home/travis/build/WordPoints/wordpoints/tests/phpunit/tests/classes/hook/extension/periods.php:742
/home/travis/.phpenv/versions/5.2.17/bin/phpunit:46
JDGrimes commented 8 years ago

I thought that this might possibly have been related to #505, but I don't think that it was (or at least not all of the failures were, because some are still happening). I have not experienced one of these locally as well, but it is not reproducible, because it is time related. I guess we'll have to really dig into the logic to figure out exactly what is going on.

JDGrimes commented 7 years ago

Looks like that fixed it. I keep forgetting that the periods use greater than instead of greater than or equals.

JDGrimes commented 7 years ago

Just discovered another one:

There was 1 failure:

1) WordPoints_Points_Hook_Extension_Legacy_Periods_Test::test_should_hit_target_changed

Failed asserting that actual size 2 matches expected size 1.

/home/travis/build/WordPoints/wordpoints/tests/phpunit/tests/classes/hook/extension/periods.php:871

Some of these can fail randomly because the use a length of only a minute, and the periods are absolute. Therefore if the test occurs during the end of a minute, the period will end, and failure will result. The solution is to use a longer period, and/or make them relative instead of absolute. I think that using a period of one day would be sufficient, event though the absolute nature of the periods isn't integral to these particular tests.