ForeignResourceManager: Ignore network errors during tests
Bug: T362425 Change-Id: Ie7e9e9bbd99c32d5b3153f1fd4a4042b437ce189
This commit is contained in:
parent
c434d89688
commit
3b276808ed
4 changed files with 21 additions and 4 deletions
|
|
@ -1958,6 +1958,7 @@ $wgAutoloadLocalClasses = [
|
|||
'MediaWiki\\ResourceLoader\\FilePath' => __DIR__ . '/includes/ResourceLoader/FilePath.php',
|
||||
'MediaWiki\\ResourceLoader\\ForeignApiModule' => __DIR__ . '/includes/ResourceLoader/ForeignApiModule.php',
|
||||
'MediaWiki\\ResourceLoader\\ForeignResourceManager' => __DIR__ . '/includes/ResourceLoader/ForeignResourceManager.php',
|
||||
'MediaWiki\\ResourceLoader\\ForeignResourceNetworkException' => __DIR__ . '/includes/ResourceLoader/ForeignResourceNetworkException.php',
|
||||
'MediaWiki\\ResourceLoader\\HookRunner' => __DIR__ . '/includes/ResourceLoader/HookRunner.php',
|
||||
'MediaWiki\\ResourceLoader\\Hook\\ResourceLoaderExcludeUserOptionsHook' => __DIR__ . '/includes/ResourceLoader/Hook/ResourceLoaderExcludeUserOptionsHook.php',
|
||||
'MediaWiki\\ResourceLoader\\Hook\\ResourceLoaderForeignApiModulesHook' => __DIR__ . '/includes/ResourceLoader/Hook/ResourceLoaderForeignApiModulesHook.php',
|
||||
|
|
|
|||
|
|
@ -297,10 +297,10 @@ class ForeignResourceManager {
|
|||
if ( $reqError !== null ) {
|
||||
$message .= ': ' . Message::newFromSpecifier( $reqError )->inLanguage( 'en' )->plain();
|
||||
}
|
||||
throw new LogicException( $message );
|
||||
throw new ForeignResourceNetworkException( $message );
|
||||
}
|
||||
if ( $req->getStatus() !== 200 ) {
|
||||
throw new LogicException( "Unexpected HTTP {$req->getStatus()} response from {$src}" );
|
||||
throw new ForeignResourceNetworkException( "Unexpected HTTP {$req->getStatus()} response from {$src}" );
|
||||
}
|
||||
$data = $req->getContent();
|
||||
$algo = $integrity === null ? $this->defaultAlgo : explode( '-', $integrity )[0];
|
||||
|
|
@ -313,7 +313,7 @@ class ForeignResourceManager {
|
|||
$this->output( "Integrity for {$src}\n\tintegrity: {$actualIntegrity}\n" );
|
||||
} else {
|
||||
$expectedIntegrity = $integrity ?? 'null';
|
||||
throw new LogicException( "Integrity check failed for {$src}\n" .
|
||||
throw new ForeignResourceNetworkException( "Integrity check failed for {$src}\n" .
|
||||
"\tExpected: {$expectedIntegrity}\n" .
|
||||
"\tActual: {$actualIntegrity}"
|
||||
);
|
||||
|
|
|
|||
11
includes/ResourceLoader/ForeignResourceNetworkException.php
Normal file
11
includes/ResourceLoader/ForeignResourceNetworkException.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\ResourceLoader;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown when a network error occurs while fetching a foreign resource.
|
||||
*/
|
||||
class ForeignResourceNetworkException extends RuntimeException {
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\ResourceLoader\ForeignResourceManager;
|
||||
use MediaWiki\ResourceLoader\ForeignResourceNetworkException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -38,6 +39,10 @@ class ForeignResourceStructureTest extends TestCase {
|
|||
$ php maintenance/manageForeignResources.php update <moduleName>
|
||||
';
|
||||
|
||||
$this->assertTrue( $frm->run( 'verify', 'all' ), "$out\n$helpUpdate" );
|
||||
try {
|
||||
$this->assertTrue( $frm->run( 'verify', 'all' ), "$out\n$helpUpdate" );
|
||||
} catch ( ForeignResourceNetworkException $e ) {
|
||||
$this->markTestSkipped( 'Network error: ' . $e->getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue