Page MenuHomePhabricator

Echo doesn't register or run any of its qunit tests
Closed, ResolvedPublic

Description

Doing T232875 I wanted to migrate qunit tests of Echo but it registers those dynamically:

	/**
	 * ResourceLoaderTestModules hook handler
	 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
	 *
	 * @param array &$testModules
	 * @param ResourceLoader $resourceLoader
	 */
	public static function onResourceLoaderTestModules( array &$testModules,
		ResourceLoader $resourceLoader = null
	) {
		global $wgResourceModules;

		$testModuleBoilerplate = [
			'localBasePath' => dirname( __DIR__ ),
			'remoteExtPath' => 'Echo',
		];

		// find test files for every RL module
		$prefix = 'ext.echo';
		foreach ( $wgResourceModules as $key => $module ) {
			if ( substr( $key, 0, strlen( $prefix ) ) === $prefix && isset( $module['scripts'] ) ) {
				$testFiles = [];
				foreach ( $module['scripts'] as $script ) {
					$testFile = 'tests/qunit/' . dirname( $script ) . '/test_' . basename( $script );
					// if a test file exists for a given JS file, add it
					if ( file_exists( $testModuleBoilerplate['localBasePath'] . '/' . $testFile ) ) {
						$testFiles[] = $testFile;
					}
				}
				// if test files exist for given module, create a corresponding test module
				if ( $testFiles !== [] ) {
					$testModules['qunit']["$key.tests"] = $testModuleBoilerplate + [
						'dependencies' => [ $key ],
						'scripts' => $testFiles,
					];
				}
			}
		}
	}

so I tried running that hook in my localhost:

amsa@amsa-Latitude-7480:/var/lib/mediawiki2$ php maintenance/eval.php 
> $m = [];

> $rl = new ResourceLoader( \MediaWiki\MediaWikiServices::getInstance()->getMainConfig() );

> EchoHooks::onResourceLoaderTestModules( $m, $rl );

> var_dump( $m );
array(0) {
}

It's empty, further investigation found that $wgResourceModules doesn't contain any of Echo's production modules (Loaded dynamically from extension.json I assume) and as the result no qunit module is being registered. I thought it's CLI but no, web doesn't have them in web either (the tests are run in CLI anyway)

Also I looked at the most recent jenkins run of Echo extension: https://integration.wikimedia.org/ci/job/wmf-quibble-vendor-mysql-php72-docker/41189/consoleFull it runs all qunit tests under "Run Qunit tests" except any qunit tests of Echo so I'm fairly certain it has not been running any of qunit tests of Echo extension.

Event Timeline

Restricted Application added a project: Growth-Team. · View Herald TranscriptJul 24 2020, 6:20 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 616163 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/extensions/Echo@master] Make Echo QUnit tests run again

https://gerrit.wikimedia.org/r/616163

Change 616163 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Make Echo QUnit tests run again

https://gerrit.wikimedia.org/r/616163

Jdforrester-WMF closed this task as Resolved.Jul 27 2020, 9:58 AM
Jdforrester-WMF assigned this task to Catrope.