Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60705

core_search: Unit tests get time wrong by factor of a million


      aolley points out that code in the mock search engine for faking time (introduced in MDL-60555) is incorrect by a factor of a million; the code used to call usleep which is measured in microseconds, and has now been changed to add to a numeric variable that is stored in seconds.

      This did not cause the unit tests to fail, which indicated somewhat of an inadequacy in the unit tests. Code in the tests was basically along the lines of:

      • Set a time limit so that only 2 items will be processed
      • Check that only 2 items were processed

      However, because of the way that search time limits work, there is usually a minimum of 2 items that need to be processed before it really even checks the time limit. (This is because it guarantees to make some progress each time, which means it has to get onto the next second; it does this by, roughly, requiring to process items with different time values, which means it must process at least 2.)

      I have changed one of the unit tests so that 3 items will be processed. This now fails as expected with the old code (that was out by a factor of a million) and passes again once that code is corrected.

            quen Sam Marshall
            quen Sam Marshall
            Adam Olley Adam Olley
            Jake Dallimore Jake Dallimore
            Adrian Greeve Adrian Greeve
            0 Vote for this issue
            4 Start watching this issue


                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.