X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=maintenance%2FcheckLess.php;h=b97e1b0b23780c85339eda4428f94f1f95e2affe;hb=62eb67626564f881e8151eb27039b4b7f13e3076;hp=d02d8a7b5cca851c142733ebeba8fe99e2f7316f;hpb=5c51cb96eaea76d22b9c48928044a942c4be2feb;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/checkLess.php b/maintenance/checkLess.php index d02d8a7b5c..b97e1b0b23 100644 --- a/maintenance/checkLess.php +++ b/maintenance/checkLess.php @@ -22,49 +22,33 @@ */ require_once __DIR__ . '/Maintenance.php'; +require_once 'PHPUnit/Autoload.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 ( !$result ) { - $this->output( "No errors found\n" ); - } else { - die( 1 ); - } + $textUICommand = new PHPUnit_TextUI_Command(); + $argv = array( + "$IP/tests/phpunit/phpunit.php", + "$IP/tests/phpunit/suites/LessTestSuite.php" + ); + $textUICommand->run( $argv ); } }