61 if ( !file_exists(
'results' ) ) {
64 if ( !is_dir(
'results' ) ) {
65 echo
"Unable to create 'results' directory\n";
68 $overallStart = microtime(
true );
69 $reportInterval = 1000;
71 for ( $i = 1;
true; $i++ ) {
72 $t = -microtime(
true );
75 self::$currentTest->execute();
77 }
catch ( Exception $e ) {
78 $testReport = self::$currentTest->getReport();
79 $exceptionReport = $e instanceof
MWException ? $e->getText() : (string)$e;
80 $hash = md5( $testReport );
81 file_put_contents(
"results/ppft-$hash.in",
serialize( self::$currentTest ) );
82 file_put_contents(
"results/ppft-$hash.fail",
83 "Input:\n$testReport\n\nException report:\n$exceptionReport\n" );
84 print "Test $hash failed\n";
87 $t += microtime(
true );
90 printf(
"Test $passed in %.3f seconds\n",
$t );
91 print self::$currentTest->getReport();
94 $reportMetric = ( microtime(
true ) - $overallStart ) / $i * $reportInterval;
95 if ( $reportMetric > 25 ) {
96 if ( substr( (
string)$reportInterval, 0, 1 ) ===
'1' ) {
101 } elseif ( $reportMetric < 4 ) {
102 if ( substr( (
string)$reportInterval, 0, 1 ) ===
'1' ) {
103 $reportInterval *= 5;
105 $reportInterval *= 2;
108 if ( $i % $reportInterval == 0 ) {
109 print "$i tests done\n";
119 if ( $max ===
false ) {
122 $length = mt_rand( $this->minLength, $max );
124 for ( $i = 0; $i < $length; $i++ ) {
125 $hairIndex = mt_rand( 0, count( $this->hairs ) - 1 );
126 $s .= $this->hairs[$hairIndex];
132 $s = MediaWikiServices::getInstance()->getContentLanguage()->normalize(
$s );