Index: trunk/extensions/LocalisationUpdate/tests/tokenTest.php |
— | — | @@ -0,0 +1,52 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== '' |
| 5 | + ? getenv( 'MW_INSTALL_PATH' ) |
| 6 | + : realpath( dirname( __FILE__ ) . "/../../../" ); |
| 7 | + |
| 8 | +require_once( "$IP/maintenance/commandLine.inc" ); |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +function evalExtractArray( $php, $varname ) { |
| 13 | + eval( $php ); |
| 14 | + return @$$varname; |
| 15 | +} |
| 16 | + |
| 17 | +function confExtractArray( $php, $varname ) { |
| 18 | + $ce = new ConfEditor("<?php $php"); |
| 19 | + $vars = $ce->getVars(); |
| 20 | + $retval = @$vars[$varname]; |
| 21 | + return $retval; |
| 22 | +} |
| 23 | + |
| 24 | +$sources = glob("$IP/languages/messages/Messages*.php"); |
| 25 | + |
| 26 | +foreach( $sources as $sourceFile ) { |
| 27 | + $sourceData = file_get_contents( $sourceFile ); |
| 28 | + $sourceData = preg_replace( "/<\\?php/", "", $sourceData ); |
| 29 | + $sourceData = preg_replace( "/\?" . ">/", "", $sourceData ); |
| 30 | + |
| 31 | + $start = microtime(true); |
| 32 | + $eval = evalExtractArray( $sourceData, 'messages' ); |
| 33 | + $deltaEval = microtime(true) - $start; |
| 34 | + |
| 35 | + $start = microtime(true); |
| 36 | + $token = confExtractArray( $sourceData, 'messages' ); |
| 37 | + $deltaToken = microtime(true) - $start; |
| 38 | + |
| 39 | + $hashEval = md5(serialize($eval)); |
| 40 | + $hashToken = md5(serialize($token)); |
| 41 | + |
| 42 | + $rel = wfRelativePath( $sourceFile, $IP ); |
| 43 | + printf( "%s %s %0.1f - eval\n", $rel, $hashEval, $deltaEval * 1000 ); |
| 44 | + printf( "%s %s %0.1f - token\n", $rel, $hashToken, $deltaToken * 1000 ); |
| 45 | + |
| 46 | + if( $hashEval !== $hashToken ) { |
| 47 | + file_put_contents( 'eval.txt', var_export( $eval, true ) ); |
| 48 | + file_put_contents( 'token.txt', var_export( $token, true ) ); |
| 49 | + die("check eval.txt and token.txt\n"); |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +echo "ok\n"; |
Property changes on: trunk/extensions/LocalisationUpdate/tests/tokenTest.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 54 | + native |