|
[MediaWiki-CVS] SVN: [54052] trunk/phase3: msg#01430mediawiki-cvs
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54052 Revision: 54052 Author: brion Date: 2009-07-30 22:24:04 +0000 (Thu, 30 Jul 2009) Log Message: ----------- * Parser test supports uploading results to remote CodeReview instance Now I just have to finish the CodeReview extension side of it... ;) Modified Paths: -------------- trunk/phase3/RELEASE-NOTES trunk/phase3/includes/DefaultSettings.php trunk/phase3/maintenance/parserTests.inc trunk/phase3/maintenance/parserTests.php Modified: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES 2009-07-30 22:11:44 UTC (rev 54051) +++ trunk/phase3/RELEASE-NOTES 2009-07-30 22:24:04 UTC (rev 54052) @@ -166,6 +166,7 @@ * (bug 9691) Add type (signup or login) parameter to AuthPlugin::ModifyUITemplate() * (bug 14454) "Member of group(s)" in Special:Preferences causes language difficulties * (bug 16697) Unicode combining characters are difficult to edit in some browsers +* Parser test supports uploading results to remote CodeReview instance === Bug fixes in 1.16 === Modified: trunk/phase3/includes/DefaultSettings.php =================================================================== --- trunk/phase3/includes/DefaultSettings.php 2009-07-30 22:11:44 UTC (rev 54051) +++ trunk/phase3/includes/DefaultSettings.php 2009-07-30 22:24:04 UTC (rev 54052) @@ -3814,6 +3814,21 @@ ); /** + * If configured, specifies target CodeReview installation to send test + * result data from 'parserTests.php --upload' + * + * Something like this: + * $wgParserTestRemote = array( + * 'api-url' => 'http://www.mediawiki.org/w/api.php', + * 'repo' => 'MediaWiki', + * 'suite' => 'ParserTests', + * 'path' => '/trunk/phase3', // not used client-side; for reference + * 'secret' => 'qmoicj3mc4mcklmqw', // Shared secret used in HMAC validation + * ); + */ +$wgParserTestRemote = false; + +/** * Break out of framesets. This can be used to prevent external sites from * framing your site with ads. */ Modified: trunk/phase3/maintenance/parserTests.inc =================================================================== --- trunk/phase3/maintenance/parserTests.inc 2009-07-30 22:11:44 UTC (rev 54051) +++ trunk/phase3/maintenance/parserTests.inc 2009-07-30 22:24:04 UTC (rev 54052) @@ -116,6 +116,8 @@ $this->recorder = new DbTestRecorder( $this ); } elseif( isset( $options['compare'] ) ) { $this->recorder = new DbTestPreviewer( $this ); + } elseif( isset( $options['upload'] ) ) { + $this->recorder = new RemoteTestRecorder( $this ); } else { $this->recorder = new TestRecorder( $this ); } @@ -1521,3 +1523,91 @@ __METHOD__ ); } } + +class RemoteTestRecorder extends TestRecorder { + function start() { + parent::start(); + $this->results = array(); + $this->ping( 'running' ); + } + + function record( $test, $result ) { + parent::record( $test, $result ); + $this->results[$test] = (bool)$result; + } + + function end() { + $this->ping( 'complete', $this->results ); + parent::end(); + } + + /** + * Inform a CodeReview instance that we've started or completed a test run... + * @param $remote array: info on remote target + * @param $status string: "running" - tell it we've started + * "complete" - provide test results array + * "abort" - something went horribly awry + * @param $data array of test name => true/false + */ + function ping( $status, $results=false ) { + global $wgParserTestRemote, $IP; + + $remote = $wgParserTestRemote; + $revId = SpecialVersion::getSvnRevision( $IP ); + $jsonResults = json_encode( $results ); + + if( !$remote ) { + print "Can't do remote upload without configuring \$wgParserTestRemote!\n"; + exit( 1 ); + } + + // Generate a hash MAC to validate our credentials + $message = array( + $remote['repo'], + $remote['suite'], + $revId, + $status, + ); + if( $status == "complete" ) { + $message[] = $jsonResults; + } + $hmac = hash_hmac( "sha1", implode( "|", $message ), $remote['secret'] ); + + $postData = array( + 'action' => 'codetestupload', + 'format' => 'json', + 'repo' => $remote['repo'], + 'suite' => $remote['suite'], + 'rev' => $revId, + 'status' => $status, + 'hmac' => $hmac, + ); + if( $status == "complete" ) { + $postData['results'] = $jsonResults; + } + $response = $this->post( $remote['api-url'], $postData ); + + if( $response === false ) { + print "CodeReview info upload failed to reach server.\n"; + exit( 1 ); + } + $responseData = json_decode( $response, true ); + if( !is_array( $responseData ) ) { + print "CodeReview API response not recognized...\n"; + wfDebug( "Unrecognized CodeReview API response: $response\n" ); + exit( 1 ); + } + if( isset( $responseData['error'] ) ) { + $code = $responseData['error']['code']; + $info = $responseData['error']['info']; + print "CodeReview info upload failed: $code $info\n"; + exit( 1 ); + } + } + + function post( $url, $data ) { + // @fixme: for whatever reason, I get a 417 fail when using CURL's multipart form submit. + // If we do form URL encoding ourselves, though, it should work. + return Http::post( $url, array( 'postdata' => wfArrayToCGI( $data ) ) ); + } +} Modified: trunk/phase3/maintenance/parserTests.php =================================================================== --- trunk/phase3/maintenance/parserTests.php 2009-07-30 22:11:44 UTC (rev 54051) +++ trunk/phase3/maintenance/parserTests.php 2009-07-30 22:24:04 UTC (rev 54052) @@ -47,8 +47,8 @@ --seed <n> Start the fuzz test from the specified seed --help Show this help message --run-disabled run disabled tests + --upload Upload test results to remote wiki (per \$wgParserTestRemote) - ENDS; exit( 0 ); } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@xxxxxxxxxxxxxxxxxxx https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|
|
||||||||||||||||||||||||||
|
|
|
| News | Mail Home | sitemap | FAQ | advertise |