Nit: Fix timing jitter in AddonConditionWatcherTriggerTimeSecs #9711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Have you been experiencing unstable unit tests in the
TestAddon::conditionWatcher_group()
test case? Well we have an exciting, limited time offer for you! A fix to the addon condition time calculation now available for the low LOW price of one r+ to this simple PR!The gist of the issue is that addon condition times are specified in seconds relative to the installation time, but the installation time is stored in milliseconds. The truncation in handling the expiration calculation can result in a second of jitter around the actual emission of the
conditionChanged()
signal. Sometimes, when the jitter overlaps we can wind up with the conditions going true in reverse order, which is what causes this test to fail.To fix this, I felt the best approach was to do all the math in milliseconds, which is kind of the native unit of the
QDateTime
class which eliminates the need to do our own timestamp math.To reproduce the issue, build the unit tests and then torture them in the following loop. Without this change it dies after a handful of iterations.
Reference
Example test failures: seen here
Checklist