r106990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106989‎ | r106990 | r106991 >
Date:22:02, 21 December 2011
Author:krinkle
Status:ok
Tags:ci 
Comment:
[TestSwarm] whitespace and minor fixes
Modified paths:
  • /trunk/tools/testswarm/scripts/testswarm-mw-fetcher-run.php (modified) (history)
  • /trunk/tools/testswarm/scripts/testswarm-mw-fetcher.php (modified) (history)

Diff [purge]

Index: trunk/tools/testswarm/scripts/testswarm-mw-fetcher-run.php
@@ -14,7 +14,7 @@
1515 $mode = 'dev';
1616 $mode = 'preprod';
1717 $mode = 'prod';
18 -if( !(count($argv) === 2 && preg_match( '/^--(dev|preprod|prod)$/', $argv[1] ) ) ) {
 18+if( !( count( $argv ) === 2 && preg_match( '/^--(dev|preprod|prod)$/', $argv[1] ) ) ) {
1919 print "$argv[0]: expects exactly one of the following options:\n\n";
2020 print " --dev : fetch only this script repository.\n";
2121 print " --preprod : fetch part of phase3 in a temp directory with debugging\n";
Index: trunk/tools/testswarm/scripts/testswarm-mw-fetcher.php
@@ -4,8 +4,7 @@
55 *
66 * As of November 2nd 2011, this is still a work in progress.
77 *
8 - * Latest version can be found in the Mediawiki repository under
9 - * /trunk/tools/testswarm/
 8+ * Latest version can be found in the MediaWiki SVN repository under /trunk/tools/testswarm/
109 *
1110 * Based on http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/testswarm/scripts/testswarm-mediawiki-svn.php?revision=94359&view=markup
1211 *
@@ -14,8 +13,10 @@
1514 */
1615
1716 /**
18 - * One class doing everything! :D
 17+ * TestSwarmMWMain
1918 *
 19+ * Main class that prepares everything.
 20+ *
2021 * Subversion calls are made using the svn binary so we do not need
2122 * to install any PECL extension.
2223 *
@@ -57,7 +58,7 @@
5859 /** URL pattern for $wgScriptPath */
5960 protected $scriptPathPattern = "/checkouts/mw/trunk/r$1";
6061 /** URL pattern to add one test. $1 is rev, $2 testname */
61 - protected $testPattern = "/checkouts/mw/trunk/r$1/tests/qunit/?filter=$2";
 62+ protected $testPattern = '/checkouts/mw/trunk/r$1/tests/qunit/?filter=$2';
6263
6364 /** GETTERS **/
6465
@@ -92,7 +93,7 @@
9394
9495 // Verify we have been given required options
9596 if ( !isset( $options['root'] ) || !isset( $options['svnUrl'] ) ) {
96 - throw new Exception( __METHOD__ . ": Required options 'root' and/or 'svnUrl' missing" );
 97+ throw new Exception( __METHOD__ . ': Required options "root" and/or "svnUrl" missing' );
9798 }
9899
99100 $this->root = $options['root'];
@@ -114,7 +115,7 @@
115116 if ( $options['minRev'] < 1 ) {
116117 # minRev = 0 will just screw any assumption made in this script.
117118 # so we really do not want it.
118 - throw new Exception( __METHOD__ . ": Option 'minRev' must be >= 1 " );
 119+ throw new Exception( __METHOD__ . ': Option "minRev" must be >= 1' );
119120 }
120121 $this->minRev = $options['minRev'];
121122 }
@@ -198,7 +199,7 @@
199200 $output = $this->exec( $cmd, $retval );
200201
201202 if ( $retval !== 0 ) {
202 - throw new Exception(__METHOD__. ': Error running subversion log' );
 203+ throw new Exception( __METHOD__. ': Error running subversion log' );
203204 }
204205
205206 preg_match( "/r(\d+)/m", $output, $m );
@@ -259,7 +260,7 @@
260261 */
261262 public function getPathsForRev( $id ) {
262263 if ( !is_numeric( $id ) ) {
263 - throw new Exception( __METHOD__ . ": Given non numerical revision " . var_export($id, true) );
 264+ throw new Exception( __METHOD__ . ': Given non numerical revision ' . var_export( $id, true ) );
264265 }
265266
266267 return array(
@@ -333,7 +334,7 @@
334335 echo "$msg\n";
335336
336337 // Append to logfile
337 - $fhandle = fopen( $file, "w+" );
 338+ $fhandle = fopen( $file, 'w+' );
338339 fwrite( $fhandle, '[' . date( 'r' ) . '] ' . $msg );
339340 fclose( $fhandle );
340341 }
@@ -374,7 +375,7 @@
375376 public function __construct( TestSwarmMWMain $main, $svnRevId ) {
376377 // Basic validation
377378 if ( !is_int( $svnRevId ) ) {
378 - throw new Exception( __METHOD__ . ": Invalid argument. svnRevId must be an integer" );
 379+ throw new Exception( __METHOD__ . ': Invalid argument. svnRevId must be an integer' );
379380 }
380381
381382 $this->paths = $main->getPathsForRev( $svnRevId );
@@ -400,9 +401,9 @@
401402
402403 /**
403404 * @todo FIXME:
404 - * - Get list of tests (see old file for how)
 405+ * - Get list of tests (see old file for how)
405406 * - Make POST request to TestSwarm install to add jobs for these test runs
406 - * (CURL addjob.php with login/auth token)
 407+ * (CURL addjob.php with login/auth token)
407408 */
408409 return true;
409410 }
@@ -425,7 +426,7 @@
426427 $retval = null;
427428 $this->main->exec( $cmd, $retval );
428429 if ( $retval !== 0 ) {
429 - throw new Exception(__METHOD__ . ": Error running subversion checkout" );
 430+ throw new Exception( __METHOD__ . ': Error running subversion checkout' );
430431 }
431432
432433 // @todo: Handle errors for above commands.
@@ -473,7 +474,7 @@
474475 $this->main->log( "-- MediaWiki installer output: \n$output\n-- End of MediaWiki installer output", __METHOD__ );
475476
476477 if ( $retval !== 0 ) {
477 - throw new Exception(__METHOD__ . ": Error running MediaWiki installer" );
 478+ throw new Exception( __METHOD__ . ': Error running MediaWiki installer' );
478479 }
479480 }
480481
@@ -486,7 +487,7 @@
487488
488489 $localSettings = "{$this->paths['mw']}/LocalSettings.php";
489490 if ( !file_exists( $localSettings ) ) {
490 - throw new Exception(__METHOD__ . ": LocalSettings.php missing, expected at {$localSettings}" );
 491+ throw new Exception( __METHOD__ . ": LocalSettings.php missing, expected at {$localSettings}" );
491492 }
492493
493494 // Optional, only if existant
@@ -502,7 +503,7 @@
503504 if ( touch( $globalSettings ) ) {
504505 $this->main->debug( "Created $globalSettings", __METHOD__ );
505506 } else {
506 - throw new Exception(__METHOD__ . ": Aborting. Unable to create GlobalSettings.php" );
 507+ throw new Exception( __METHOD__ . ": Aborting. Unable to create GlobalSettings.php" );
507508 }
508509 }
509510
@@ -576,18 +577,18 @@
577578
578579 # Append each of our test file to the job query submission
579580 foreach( $filenames as $filename) {
580 - if ( substr( $filename, -8 ) === '.test.js' ) {
581 - $suiteName = substr( $filename, 0, -8 );
 581+ if ( substr( $filename, -8 ) === '.test.js' ) {
 582+ $suiteName = substr( $filename, 0, -8 );
582583 $pattern = $this->context->getTestPattern();
583584
584585 $testUrl = str_replace( array( '$1', '$2' ),
585586 array( rawurlencode($revision), rawurlencode($suiteName) ),
586587 $pattern
587588 );
588 - $query .=
589 - "&suites[]=" . rawurlencode( $suiteName ) .
590 - "&urls[]=" . $testUrl."\n";
591 - }
 589+ $query .=
 590+ '&suites[]=' . rawurlencode( $suiteName ) .
 591+ '&urls[]=' . $testUrl . "\n";
 592+ }
592593 }
593594
594595 //print "Testswarm base URL: {$this->URL}\n";
@@ -596,13 +597,13 @@
597598 # Forge curl request and submit it
598599 $ch = curl_init();
599600 curl_setopt_array( $ch, array(
600 - CURLOPT_RETURNTRANSFER => 1
601 - , CURLOPT_USERAGENT => "TestSwarm-fetcher (ContInt; hashar)"
602 - , CURLOPT_SSL_VERIFYHOST => FALSE
603 - , CURLOPT_SSL_VERIFYPEER => FALSE
604 - , CURLOPT_POST => TRUE
605 - , CURLOPT_URL => $this->URL
606 - , CURLOPT_POSTFIELDS => $query
 601+ CURLOPT_RETURNTRANSFER => 1,
 602+ CURLOPT_USERAGENT => 'TestSwarm-fetcher (ContInt; hashar)',
 603+ CURLOPT_SSL_VERIFYHOST => false,
 604+ CURLOPT_SSL_VERIFYPEER => false,
 605+ CURLOPT_POST => true,
 606+ CURLOPT_URL => $this->URL,
 607+ CURLOPT_POSTFIELDS => $query,
607608 ));
608609 $ret = curl_exec( $ch );
609610 $err = curl_errno( $ch );

Status & tagging log