Index: trunk/tools/testswarm/scripts/testswarm-mw-fetcher-run.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | $mode = 'dev'; |
16 | 16 | $mode = 'preprod'; |
17 | 17 | $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] ) ) ) { |
19 | 19 | print "$argv[0]: expects exactly one of the following options:\n\n"; |
20 | 20 | print " --dev : fetch only this script repository.\n"; |
21 | 21 | 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 @@ |
5 | 5 | * |
6 | 6 | * As of November 2nd 2011, this is still a work in progress. |
7 | 7 | * |
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/ |
10 | 9 | * |
11 | 10 | * Based on http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/testswarm/scripts/testswarm-mediawiki-svn.php?revision=94359&view=markup |
12 | 11 | * |
— | — | @@ -14,8 +13,10 @@ |
15 | 14 | */ |
16 | 15 | |
17 | 16 | /** |
18 | | - * One class doing everything! :D |
| 17 | + * TestSwarmMWMain |
19 | 18 | * |
| 19 | + * Main class that prepares everything. |
| 20 | + * |
20 | 21 | * Subversion calls are made using the svn binary so we do not need |
21 | 22 | * to install any PECL extension. |
22 | 23 | * |
— | — | @@ -57,7 +58,7 @@ |
58 | 59 | /** URL pattern for $wgScriptPath */ |
59 | 60 | protected $scriptPathPattern = "/checkouts/mw/trunk/r$1"; |
60 | 61 | /** 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'; |
62 | 63 | |
63 | 64 | /** GETTERS **/ |
64 | 65 | |
— | — | @@ -92,7 +93,7 @@ |
93 | 94 | |
94 | 95 | // Verify we have been given required options |
95 | 96 | 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' ); |
97 | 98 | } |
98 | 99 | |
99 | 100 | $this->root = $options['root']; |
— | — | @@ -114,7 +115,7 @@ |
115 | 116 | if ( $options['minRev'] < 1 ) { |
116 | 117 | # minRev = 0 will just screw any assumption made in this script. |
117 | 118 | # 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' ); |
119 | 120 | } |
120 | 121 | $this->minRev = $options['minRev']; |
121 | 122 | } |
— | — | @@ -198,7 +199,7 @@ |
199 | 200 | $output = $this->exec( $cmd, $retval ); |
200 | 201 | |
201 | 202 | if ( $retval !== 0 ) { |
202 | | - throw new Exception(__METHOD__. ': Error running subversion log' ); |
| 203 | + throw new Exception( __METHOD__. ': Error running subversion log' ); |
203 | 204 | } |
204 | 205 | |
205 | 206 | preg_match( "/r(\d+)/m", $output, $m ); |
— | — | @@ -259,7 +260,7 @@ |
260 | 261 | */ |
261 | 262 | public function getPathsForRev( $id ) { |
262 | 263 | 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 ) ); |
264 | 265 | } |
265 | 266 | |
266 | 267 | return array( |
— | — | @@ -333,7 +334,7 @@ |
334 | 335 | echo "$msg\n"; |
335 | 336 | |
336 | 337 | // Append to logfile |
337 | | - $fhandle = fopen( $file, "w+" ); |
| 338 | + $fhandle = fopen( $file, 'w+' ); |
338 | 339 | fwrite( $fhandle, '[' . date( 'r' ) . '] ' . $msg ); |
339 | 340 | fclose( $fhandle ); |
340 | 341 | } |
— | — | @@ -374,7 +375,7 @@ |
375 | 376 | public function __construct( TestSwarmMWMain $main, $svnRevId ) { |
376 | 377 | // Basic validation |
377 | 378 | 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' ); |
379 | 380 | } |
380 | 381 | |
381 | 382 | $this->paths = $main->getPathsForRev( $svnRevId ); |
— | — | @@ -400,9 +401,9 @@ |
401 | 402 | |
402 | 403 | /** |
403 | 404 | * @todo FIXME: |
404 | | - * - Get list of tests (see old file for how) |
| 405 | + * - Get list of tests (see old file for how) |
405 | 406 | * - 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) |
407 | 408 | */ |
408 | 409 | return true; |
409 | 410 | } |
— | — | @@ -425,7 +426,7 @@ |
426 | 427 | $retval = null; |
427 | 428 | $this->main->exec( $cmd, $retval ); |
428 | 429 | if ( $retval !== 0 ) { |
429 | | - throw new Exception(__METHOD__ . ": Error running subversion checkout" ); |
| 430 | + throw new Exception( __METHOD__ . ': Error running subversion checkout' ); |
430 | 431 | } |
431 | 432 | |
432 | 433 | // @todo: Handle errors for above commands. |
— | — | @@ -473,7 +474,7 @@ |
474 | 475 | $this->main->log( "-- MediaWiki installer output: \n$output\n-- End of MediaWiki installer output", __METHOD__ ); |
475 | 476 | |
476 | 477 | if ( $retval !== 0 ) { |
477 | | - throw new Exception(__METHOD__ . ": Error running MediaWiki installer" ); |
| 478 | + throw new Exception( __METHOD__ . ': Error running MediaWiki installer' ); |
478 | 479 | } |
479 | 480 | } |
480 | 481 | |
— | — | @@ -486,7 +487,7 @@ |
487 | 488 | |
488 | 489 | $localSettings = "{$this->paths['mw']}/LocalSettings.php"; |
489 | 490 | 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}" ); |
491 | 492 | } |
492 | 493 | |
493 | 494 | // Optional, only if existant |
— | — | @@ -502,7 +503,7 @@ |
503 | 504 | if ( touch( $globalSettings ) ) { |
504 | 505 | $this->main->debug( "Created $globalSettings", __METHOD__ ); |
505 | 506 | } else { |
506 | | - throw new Exception(__METHOD__ . ": Aborting. Unable to create GlobalSettings.php" ); |
| 507 | + throw new Exception( __METHOD__ . ": Aborting. Unable to create GlobalSettings.php" ); |
507 | 508 | } |
508 | 509 | } |
509 | 510 | |
— | — | @@ -576,18 +577,18 @@ |
577 | 578 | |
578 | 579 | # Append each of our test file to the job query submission |
579 | 580 | 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 ); |
582 | 583 | $pattern = $this->context->getTestPattern(); |
583 | 584 | |
584 | 585 | $testUrl = str_replace( array( '$1', '$2' ), |
585 | 586 | array( rawurlencode($revision), rawurlencode($suiteName) ), |
586 | 587 | $pattern |
587 | 588 | ); |
588 | | - $query .= |
589 | | - "&suites[]=" . rawurlencode( $suiteName ) . |
590 | | - "&urls[]=" . $testUrl."\n"; |
591 | | - } |
| 589 | + $query .= |
| 590 | + '&suites[]=' . rawurlencode( $suiteName ) . |
| 591 | + '&urls[]=' . $testUrl . "\n"; |
| 592 | + } |
592 | 593 | } |
593 | 594 | |
594 | 595 | //print "Testswarm base URL: {$this->URL}\n"; |
— | — | @@ -596,13 +597,13 @@ |
597 | 598 | # Forge curl request and submit it |
598 | 599 | $ch = curl_init(); |
599 | 600 | 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, |
607 | 608 | )); |
608 | 609 | $ret = curl_exec( $ch ); |
609 | 610 | $err = curl_errno( $ch ); |