mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Don't ship data for skipped tests to JS test code
In local testing, this reduces the amount of data loaded by Special:JavaScriptTest from 27 MB to 20 MB. Change-Id: I37f0f677751031cc965d1921a62871154bbe9201
This commit is contained in:
parent
454e15e8aa
commit
8e570a742b
|
@ -158,12 +158,39 @@ class ResourceLoaderData {
|
|||
* @return RL\Module
|
||||
*/
|
||||
public static function makeTestModule( array $info ): RL\Module {
|
||||
// Some tests rely on PHP-only features or are too large for the Karma test runner.
|
||||
// Skip them here. They are still tested in the PHP version.
|
||||
$skipTests = [
|
||||
'cases/modified.json' => [
|
||||
// Too large, cause timeouts in Karma test runner
|
||||
'enwiki oldparser',
|
||||
'enwiki parsoid',
|
||||
'enwiki oldparser (bullet indentation)',
|
||||
'enwiki parsoid (bullet indentation)',
|
||||
// These tests depend on #getTranscludedFrom(), which we didn't implement in JS
|
||||
'arwiki no-paragraph parsoid',
|
||||
'enwiki parsoid',
|
||||
'Many comments consisting of a block template and a paragraph',
|
||||
'Comment whose range almost exactly matches a template, but is not considered transcluded (T313100)',
|
||||
'Accidental complex transclusion (T265528)',
|
||||
'Accidental complex transclusion (T313093)',
|
||||
],
|
||||
];
|
||||
$info['packageFiles'][] = [
|
||||
'name' => 'skip.json',
|
||||
'type' => 'data',
|
||||
'content' => $skipTests,
|
||||
];
|
||||
|
||||
$keys = [ 'config', 'data', 'dom', 'expected' ];
|
||||
foreach ( $info['testData'] as $path ) {
|
||||
$info['packageFiles'][] = $path;
|
||||
$localPath = $info['localBasePath'] . '/' . $path;
|
||||
$data = json_decode( file_get_contents( $localPath ), true );
|
||||
foreach ( $data as $case ) {
|
||||
if ( isset( $case['name'] ) && in_array( $case['name'], $skipTests[$path] ?? [] ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $case as $key => $val ) {
|
||||
if ( in_array( $key, $keys ) && is_string( $val ) ) {
|
||||
if ( str_ends_with( $val, '.json' ) ) {
|
||||
|
|
|
@ -9,30 +9,11 @@ require( '../cases/modified.json' ).forEach( function ( caseItem ) {
|
|||
var testName = '#addListItem/#removeAddedListItem (' + caseItem.name + ')';
|
||||
// This should be one test with many cases, rather than multiple tests, but the cases are large
|
||||
// enough that processing all of them at once causes timeouts in Karma test runner.
|
||||
// FIXME: Actually, even single test cases cause timeouts now. Skip the slowest ones.
|
||||
var skipTests = [
|
||||
'enwiki oldparser',
|
||||
'enwiki parsoid',
|
||||
'enwiki oldparser (bullet indentation)',
|
||||
'enwiki parsoid (bullet indentation)'
|
||||
];
|
||||
var skipTests = require( '../skip.json' )[ 'cases/modified.json' ];
|
||||
if ( skipTests.indexOf( caseItem.name ) !== -1 ) {
|
||||
QUnit.skip( testName );
|
||||
return;
|
||||
}
|
||||
// These tests depend on #getTranscludedFrom(), which we didn't implement in JS
|
||||
var haveTranscludedComments = [
|
||||
'arwiki no-paragraph parsoid',
|
||||
'enwiki parsoid',
|
||||
'Many comments consisting of a block template and a paragraph',
|
||||
'Comment whose range almost exactly matches a template, but is not considered transcluded (T313100)',
|
||||
'Accidental complex transclusion (T265528)',
|
||||
'Accidental complex transclusion (T313093)'
|
||||
];
|
||||
if ( haveTranscludedComments.indexOf( caseItem.name ) !== -1 ) {
|
||||
QUnit.skip( testName );
|
||||
return;
|
||||
}
|
||||
QUnit.test( testName, function ( assert ) {
|
||||
var dom = ve.createDocumentFromHtml( require( '../' + caseItem.dom ) ),
|
||||
expected = ve.createDocumentFromHtml( require( '../' + caseItem.expected ) ),
|
||||
|
|
Loading…
Reference in a new issue