X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcheckLess.php;h=2f533cf4b0472bea91d131c9f6fd605fcd8a02b9;hb=0c9dc0f8f92ab7a9d7432ddcce0605d16d1aaf07;hp=d02d8a7b5cca851c142733ebeba8fe99e2f7316f;hpb=0aa4ff814eb885ebe23697aabc2311afaeb5a5f8;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/checkLess.php b/maintenance/checkLess.php index d02d8a7b5c..2f533cf4b0 100644 --- a/maintenance/checkLess.php +++ b/maintenance/checkLess.php @@ -27,44 +27,38 @@ require_once __DIR__ . '/Maintenance.php'; * @ingroup Maintenance */ class CheckLess extends Maintenance { + public function __construct() { parent::__construct(); - $this->mDescription = 'Checks LESS files for errors'; + $this->mDescription = + 'Checks LESS files for errors by running the LessTestSuite PHPUnit test suite'; } public function execute() { - $result = false; - $resourceLoader = new ResourceLoader(); - foreach ( $resourceLoader->getModuleNames() as $name ) { - /** @var ResourceLoaderFileModule $module */ - $module = $resourceLoader->getModule( $name ); - if ( !$module || !$module instanceof ResourceLoaderFileModule ) { - continue; - } + global $IP; + + // NOTE (phuedx, 2014-03-26) wgAutoloadClasses isn't set up + // by either of the dependencies at the top of the file, so + // require it here. + require_once __DIR__ . '/../tests/TestsAutoLoader.php'; - $hadErrors = false; - foreach ( $module->getAllStyleFiles() as $file ) { - if ( $module->getStyleSheetLang( $file ) !== 'less' ) { - continue; - } - try { - $compiler = ResourceLoader::getLessCompiler(); - $compiler->compileFile( $file ); - } catch ( Exception $e ) { - if ( !$hadErrors ) { - $this->error( "Errors checking module $name:\n" ); - $hadErrors = true; - } - $this->error( $e->getMessage() . "\n" ); - $result = true; - } - } + // If phpunit isn't available by autoloader try pulling it in + if ( !class_exists( 'PHPUnit_Framework_TestCase' ) ) { + require_once 'PHPUnit/Autoload.php'; } - if ( !$result ) { - $this->output( "No errors found\n" ); - } else { - die( 1 ); + + // RequestContext::resetMain() will print warnings unless this + // is defined. + if ( !defined( 'MW_PHPUNIT_TEST' ) ) { + define( 'MW_PHPUNIT_TEST', true ); } + + $textUICommand = new PHPUnit_TextUI_Command(); + $argv = array( + "$IP/tests/phpunit/phpunit.php", + "$IP/tests/phpunit/suites/LessTestSuite.php" + ); + $textUICommand->run( $argv ); } }