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:
Bartosz Dziewoński 2023-03-29 01:42:49 +02:00
parent 454e15e8aa
commit 8e570a742b
2 changed files with 28 additions and 20 deletions

View file

@ -158,12 +158,39 @@ class ResourceLoaderData {
* @return RL\Module * @return RL\Module
*/ */
public static function makeTestModule( array $info ): 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' ]; $keys = [ 'config', 'data', 'dom', 'expected' ];
foreach ( $info['testData'] as $path ) { foreach ( $info['testData'] as $path ) {
$info['packageFiles'][] = $path; $info['packageFiles'][] = $path;
$localPath = $info['localBasePath'] . '/' . $path; $localPath = $info['localBasePath'] . '/' . $path;
$data = json_decode( file_get_contents( $localPath ), true ); $data = json_decode( file_get_contents( $localPath ), true );
foreach ( $data as $case ) { foreach ( $data as $case ) {
if ( isset( $case['name'] ) && in_array( $case['name'], $skipTests[$path] ?? [] ) ) {
continue;
}
foreach ( $case as $key => $val ) { foreach ( $case as $key => $val ) {
if ( in_array( $key, $keys ) && is_string( $val ) ) { if ( in_array( $key, $keys ) && is_string( $val ) ) {
if ( str_ends_with( $val, '.json' ) ) { if ( str_ends_with( $val, '.json' ) ) {

View file

@ -9,30 +9,11 @@ require( '../cases/modified.json' ).forEach( function ( caseItem ) {
var testName = '#addListItem/#removeAddedListItem (' + caseItem.name + ')'; var testName = '#addListItem/#removeAddedListItem (' + caseItem.name + ')';
// This should be one test with many cases, rather than multiple tests, but the cases are large // 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. // 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 = require( '../skip.json' )[ 'cases/modified.json' ];
var skipTests = [
'enwiki oldparser',
'enwiki parsoid',
'enwiki oldparser (bullet indentation)',
'enwiki parsoid (bullet indentation)'
];
if ( skipTests.indexOf( caseItem.name ) !== -1 ) { if ( skipTests.indexOf( caseItem.name ) !== -1 ) {
QUnit.skip( testName ); QUnit.skip( testName );
return; 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 ) { QUnit.test( testName, function ( assert ) {
var dom = ve.createDocumentFromHtml( require( '../' + caseItem.dom ) ), var dom = ve.createDocumentFromHtml( require( '../' + caseItem.dom ) ),
expected = ve.createDocumentFromHtml( require( '../' + caseItem.expected ) ), expected = ve.createDocumentFromHtml( require( '../' + caseItem.expected ) ),