r101346 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101345‎ | r101346 | r101347 >
Date:10:15, 31 October 2011
Author:hashar
Status:resolved
Tags:
Comment:
now explicitly need to register test modules.

Previously, the javascript test modules were always registered even
when the feature was disabled. This patch convert the registration
to RL method. You will have to call that method to explicitly register
the module.

Follow up r100392
Modified paths:
  • /branches/JSTesting/includes/resourceloader/ResourceLoader.php (modified) (history)
  • /branches/JSTesting/includes/specials/SpecialJavaScriptTest.php (modified) (history)

Diff [purge]

Index: branches/JSTesting/includes/resourceloader/ResourceLoader.php
@@ -187,7 +187,7 @@
188188 * Registers core modules and runs registration hooks.
189189 */
190190 public function __construct() {
191 - global $IP, $wgResourceModules, $wgResourceLoaderSources, $wgLoadScript, $wgEnableJavaScriptTest;
 191+ global $IP, $wgResourceModules, $wgResourceLoaderSources, $wgLoadScript;
192192
193193 wfProfileIn( __METHOD__ );
194194
@@ -199,36 +199,13 @@
200200
201201 // Register core modules
202202 $this->register( include( "$IP/resources/Resources.php" ) );
 203+
203204 // Register extension modules
204205 wfRunHooks( 'ResourceLoaderRegisterModules', array( &$this ) );
205206 $this->register( $wgResourceModules );
206207
207 - if ( $wgEnableJavaScriptTest === true ) {
208208
209 - // Get core test suites
210 - $testModules = array();
211 - $testModules['qunit'] = include( "$IP/tests/qunit/QUnitTestResources.php" );
212 - // Get other test suites (e.g. from extensions)
213 - wfRunHooks( 'ResourceLoaderTestModules', array( &$testModules, &$this ) );
214209
215 - // Add the testrunner (which configures QUnit) to the dependencies.
216 - // Since it must be ready before any of the test suites are executed.
217 - foreach( $testModules['qunit'] as $moduleName => $moduleProps ) {
218 - $testModules['qunit'][$moduleName]['dependencies'][] = 'mediawiki.tests.qunit.testrunner';
219 - }
220 -
221 - foreach( $testModules as $id => $names ) {
222 - // Register test modules
223 - $this->register( $testModules[$id] );
224 -
225 - // Keep track of their names so that they can be loaded together
226 - $this->testModuleNames[$id] = array_keys( $testModules[$id] );
227 - }
228 -
229 - }
230 -
231 -
232 -
233210 wfProfileOut( __METHOD__ );
234211 }
235212
@@ -292,6 +269,39 @@
293270 }
294271
295272 /**
 273+ */
 274+ public function registerTestModules() {
 275+ global $wgEnableJavaScriptTest, $IP;
 276+ if ( $wgEnableJavaScriptTest === false ) {
 277+ throw new MWException( 'Attempt to register JavaScript test modules but <tt>$wgEnableJavaScriptTest</tt> is false. Edit your <tt>LocalSettings.php</tt> to enable it.' );
 278+ }
 279+
 280+ wfProfileIn( __METHOD__ );
 281+
 282+ // Get core test suites
 283+ $testModules = array();
 284+ $testModules['qunit'] = include( "$IP/tests/qunit/QUnitTestResources.php" );
 285+ // Get other test suites (e.g. from extensions)
 286+ wfRunHooks( 'ResourceLoaderTestModules', array( &$testModules, &$this ) );
 287+
 288+ // Add the testrunner (which configures QUnit) to the dependencies.
 289+ // Since it must be ready before any of the test suites are executed.
 290+ foreach( $testModules['qunit'] as $moduleName => $moduleProps ) {
 291+ $testModules['qunit'][$moduleName]['dependencies'][] = 'mediawiki.tests.qunit.testrunner';
 292+ }
 293+
 294+ foreach( $testModules as $id => $names ) {
 295+ // Register test modules
 296+ $this->register( $testModules[$id] );
 297+
 298+ // Keep track of their names so that they can be loaded together
 299+ $this->testModuleNames[$id] = array_keys( $testModules[$id] );
 300+ }
 301+
 302+ wfProfileOut( __METHOD__ );
 303+ }
 304+
 305+ /**
296306 * Add a foreign source of modules.
297307 *
298308 * Source properties:
Index: branches/JSTesting/includes/specials/SpecialJavaScriptTest.php
@@ -29,6 +29,8 @@
3030 return;
3131 }
3232
 33+ $out->getResourceLoader()->registerTestModules();
 34+
3335 $out->addModules( 'mediawiki.special.javaScriptTest' );
3436
3537 // Determine framework

Follow-up revisions

RevisionCommit summaryAuthorDate
r101352unconditionally register the test modules...hashar11:51, 31 October 2011
r101353remove exception added by r101346...hashar11:56, 31 October 2011
r101383[JSTesting] Restore loading principle....krinkle18:56, 31 October 2011
r101384[JSTesting] Match the other wgEnableJavaScriptTest checks (just in case)....krinkle18:57, 31 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100392[JSTesting] Initial stab at implementing on-wiki running of unit tests with Q...krinkle23:11, 20 October 2011

Status & tagging log