Previously, no profiling data was recorded from unit test runs.
That made it impossible to a) use unit tests for selective profiling
of individual functions, and b) made it impossibel to profile
the tests themselves.
This change fixes this problem by calling wfLogProfilingData()
after the test runner has finished.
Thaks to Hashar for some ideas, especially the fix in GlobalFunctions.
Change-Id: Iaa295115f3c4eb3b529388dcd953fe8932448b3e
if ( $wgUser->isItemLoaded( 'id' ) && $wgUser->isAnon() ) {
$forward .= ' anon';
}
+
+ // Command line script uses a FauxRequest object which does not have
+ // any knowledge about an URL and throw an exception instead.
+ try {
+ $requestUrl = $wgRequest->getRequestURL();
+ } catch ( MWException $e ) {
+ $requestUrl = 'n/a';
+ }
+
$log = sprintf( "%s\t%04.3f\t%s\n",
gmdate( 'YmdHis' ), $elapsed,
- urldecode( $wgRequest->getRequestURL() . $forward ) );
+ urldecode( $requestUrl . $forward ) );
wfErrorLog( $log . $profiler->getOutput(), $wgDebugLogFile );
}
}
}
+ public function run( array $argv, $exit = true ) {
+ $ret = parent::run( $argv, false );
+
+ // Return to real wiki db, so profiling data is preserved
+ MediaWikiTestCase::teardownTestDB();
+
+ // Log profiling data, e.g. in the database or UDP
+ wfLogProfilingData();
+
+ if ( $exit ) {
+ exit( $ret );
+ } else {
+ return $ret;
+ }
+ }
+
public function showHelp() {
parent::showHelp();