Tests: Fix race-condition broken mw.loader unit test
authorTimo Tijhof <ttijhof@wikimedia.org>
Fri, 29 Jun 2012 08:34:12 +0000 (10:34 +0200)
committerTimo Tijhof <ttijhof@wikimedia.org>
Mon, 2 Jul 2012 19:49:32 +0000 (21:49 +0200)
commit5583d10bdc29ee07aa5b5c62af2fb53b49846ae7
tree47dc98e46a6af5d687b6f29b4e5d61ad1d3b0561
parentb224e87ba9931a9b42d06db2dd80152d3b7aa961
Tests: Fix race-condition broken mw.loader unit test

* testloader.php was resolving dependencies when it shouldn't
  the server *never* does that. That's handled by the client, which
  knows the state of what is and isn't module.

  Due to a race condition between:
  - handlePending() call from loader.state() call for
    load.phpmodules?=testMissing
  - asynchronous callback from mw.loader.using as dependencies
    are being resolved.

  It didn't expose any actual problem, the unit test was simply
  assuming that they would arrive in a certain order, when that isn't
  the case by design.

  Random failures are seen here:
  - https://integration.mediawiki.org/testswarm/user/mediawiki/
  - http://integration.wmflabs.org/testswarm/job/4

  > Module "test.missing" must have state "missing"
  > - "missing"
  > + "loading"
  -> Because callback was triggered from mw.loader.state() already
     it didn't get to the implement() call yet.

  > Module "test.use_missing" must have state "error"
  > - "error"
  > + "loading"
  -> (same reason)

  This is now fixed.

* Greatly simplified the mock load.php

Change-Id: I000ee726a062f6c6d630ad6c07cfc0b48d145d35
tests/qunit/data/load.mock.php [new file with mode: 0644]
tests/qunit/data/testloader.php [deleted file]
tests/qunit/suites/resources/mediawiki/mediawiki.test.js