Changeset 1044
- Timestamp:
- 02/23/10 15:31:34 (5 months ago)
- Location:
- trunk/rphp-testsuite
- Files:
-
- 2 added
- 3 modified
-
Makefile (modified) (1 diff)
-
dotest.php (modified) (19 diffs)
-
re-tests/main/basic-literals.phpt (modified) (1 diff)
-
re-tests/transforms (added)
-
re-tests/transforms/SimplifyStrings.phpt (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/rphp-testsuite/Makefile
r921 r1044 37 37 php -f ./dotest.php -- -d ./re-tests/ ./re-output 38 38 39 # raven parse40 parse:41 php -f ./dotest.php -- - -parseonly -d ./re-tests/ ./re-output39 # raven transforms 40 transforms: 41 php -f ./dotest.php -- -d ./re-tests/transforms/ ./re-output 42 42 43 43 # zend -
trunk/rphp-testsuite/dotest.php
r940 r1044 3 3 /* ***** BEGIN LICENSE BLOCK ***** 4 4 * Roadsend PHP Compiler 5 * Copyright (C) 2009 Shannon Weyrick5 * Copyright (C) 2009-2010 Shannon Weyrick 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 36 36 static public $rphpBinary; 37 37 static public $rphpABinary; 38 static public $rphpVersion; 39 static public $doCompiled = true; 38 static public $rphpVersion; 40 39 static public $testRoot; 41 40 static public $outDir; 42 41 static public $singleMode = false; 43 static public $parseOnly = false;44 42 45 43 public static function log($level, $msg) { … … 66 64 } 67 65 if (empty(self::$rphpBinary) || empty(self::$rphpABinary)) { 68 self::bomb('Unable to find rphp binaries (rphp,rphp-analyze ). Try setting RPHP_BINARY and RPHP_ANALYZER_BINARY or putting rphp in the PATH');66 self::bomb('Unable to find rphp binaries (rphp,rphp-analyzer). Try setting RPHP_BINARY and RPHP_ANALYZER_BINARY or putting rphp in the PATH'); 69 67 } 70 68 } … … 98 96 public function usage() { 99 97 echo "Roadsend PHP Test Suite\n"; 100 echo "dotest [--parseonly] [-dfl] <directory or file> [output directory]\n"; 101 echo " --parseonly\t\tRun parser (AST dump) tests only, no runtime\n"; 98 echo "dotest [-df] <directory or file> [output directory]\n"; 102 99 echo " -d <path>\t\tRun all tests in the specified root directory\n"; 103 100 echo " -f <file>\t\tRun the single test specified\n"; 104 echo " -l <file>\t\tRun all tests listed in the specified file\n";105 101 die("\n"); 106 102 } … … 128 124 129 125 public function run() { 130 131 if ($GLOBALS['argv'][1] == '--parseonly') {132 Control::$parseOnly = true;133 Control::$doCompiled = false;134 array_splice($GLOBALS['argv'],1,1);135 }136 126 137 127 if (($GLOBALS['argc'] < 3) || … … 175 165 176 166 public function showResults() { 167 168 $allPassed = true; 177 169 foreach ($this->testList as $testH) { 178 170 if ($testH->interpretResult == PHP_Test::RESULT_FAIL) … … 184 176 if ($testH->compileResult == PHP_Test::RESULT_FAIL) 185 177 $cFail[] = $testH; 186 } 187 if (sizeof($iFail)) { 188 echo "------------- INTERPRETER FAILURES -------------\n"; 189 foreach ($iFail as $testH) { 178 if ($testH->parseResult == PHP_Test::RESULT_FAIL) 179 $pFail[] = $testH; 180 } 181 if (sizeof($iFail)||sizeof($bFail)||sizeof($bFailFail)||sizeof($cFail)||sizeof($pFail)) 182 $allPassed = false; 183 184 $this->showResultList('INTERPRETER', $iFail, $testH->iDiffOutput, $testH->ierrFileName); 185 $this->showResultList('BUILD', $bFail, $testH->builtOutput, $testH->buildErrFileName); 186 $this->showResultList('EXPECTED BUILD FAIL', $bFailFail, $testH->builtOutput, $testH->buildErrFileName); 187 $this->showResultList('COMPILED RUN', $cFail, $testH->cDiffOutput); 188 $this->showResultList('PARSE', $pFail, $testH->pDiffOutput); 189 190 if ($allPassed) 191 echo "---- ALL TESTS PASSED ----\n"; 192 } 193 194 public function showResultList($msg, $fails, $singleExtra=NULL, $extraFile=NULL) { 195 if (sizeof($fails)) { 196 echo "------------- $msg FAILURES -------------\n"; 197 foreach ($fails as $testH) { 190 198 echo "{$testH->tptFileName}\n"; 191 199 if (isset($testH->sectionData['KNOWNFAILURE'])) 192 200 echo "--- KNOWN FAILURE:\n".$testH->sectionData['KNOWNFAILURE']."---\n"; 193 201 if (Control::$singleMode) { 194 echo $testH->iDiffOutput; 195 if (filesize($testH->ierrFileName)) { 202 if ($singleExtra) { 203 echo $singleExtra; 204 } 205 if ($extraFile && file_exists($extraFile)) { 196 206 echo "--- ERROR OUTPUT ---\n"; 197 echo file_get_contents($ testH->ierrFileName);207 echo file_get_contents($extraFile); 198 208 } 199 209 } 200 210 } 201 211 } 202 if (sizeof($bFail)) {203 echo "------------- BUILD FAILURES -------------\n";204 foreach ($bFail as $testH) {205 echo "{$testH->tptFileName}\n";206 if (Control::$singleMode) {207 echo $testH->buildOutput;208 echo file_get_contents($testH->buildErrFileName);209 }210 }211 }212 if (sizeof($bFailFail)) {213 echo "------------- EXPECTED BUILD FAIL FAILURES -------------\n";214 foreach ($bFailFail as $testH) {215 echo "{$testH->tptFileName}\n";216 if (Control::$singleMode) {217 echo $testH->buildOutput;218 echo file_get_contents($testH->buildErrFileName);219 }220 }221 }222 if (sizeof($cFail)) {223 echo "------------- COMPILE RUN FAILURES -------------\n";224 foreach ($cFail as $testH) {225 echo "{$testH->tptFileName}\n";226 if (Control::$singleMode)227 echo $testH->cDiffOutput;228 }229 }230 if (empty($iFail)&&empty($bFail)&&empty($bFailFail)&&empty($cFail))231 echo "---- ALL TESTS PASSED ----\n";232 212 } 233 213 … … 244 224 const RESULT_BUILDFAIL_FAIL = 6; // we expected the compiler build to fail, but it passed 245 225 246 const INTERPRETER = 0; 247 const COMPILER = 1; 226 const INTERPRETER = 1; 227 const COMPILER = 2; 228 const ANALYZER = 4; 229 230 public $testTypes = 0; 248 231 249 232 public $tptFileName; … … 251 234 public $ioutFileName; // interpreted output 252 235 public $coutFileName; // compiled output 236 public $poutFileName; // parse output 253 237 public $expectFileName; 254 238 public $buildFileName; 255 239 public $idiffFileName; 256 240 public $cdiffFileName; 241 public $pdiffFileName; 257 242 public $idiffOutput; 258 243 public $cdiffOutput; 259 244 public $buildOutput; 245 public $pdiffOutput; 260 246 261 247 public $iOutput; 262 248 public $cOutput; 249 public $pOutput; 263 250 264 251 protected $expectType = 'EXPECT'; … … 269 256 public $compileResult = self::RESULT_UNKNOWN; 270 257 public $interpretResult = self::RESULT_UNKNOWN; 258 public $parseResult = self::RESULT_UNKNOWN; 271 259 272 260 public function __construct($fName) { … … 308 296 $this->sectionData['EXPECTREGEX'] = $this->sectionData['EXPECTREGEX:'.$wSize]; 309 297 310 311 298 // verify we have code to write 312 299 if (empty($this->sectionData['FILE'])) … … 314 301 315 302 if (isset($this->sectionData['EXPECTF'])) { 303 $this->testTypes |= self::COMPILER & self::INTERPRETER; 316 304 $this->expectType = 'EXPECTF'; 317 305 } 318 306 elseif (isset($this->sectionData['EXPECTREGEX'])) { 307 $this->testTypes |= self::COMPILER & self::INTERPRETER; 319 308 $this->expectType = 'EXPECTREGEX'; 320 309 } 321 elseif (!isset($this->sectionData['EXPECT'])) { 310 elseif (isset($this->sectionData['EXPECTPARSE'])) { 311 $this->testTypes |= self::ANALYZER; 312 $this->expectType = 'EXPECTPARSE'; 313 } 314 elseif (isset($this->sectionData['EXPECT'])) { 315 $this->testTypes |= self::COMPILER & self::INTERPRETER; 316 $this->expectType = 'EXPECT'; 317 } 318 else { 322 319 print_r($this->sectionData); 323 320 Control::bomb('no expect data'); 324 321 } 325 322 323 // XXX do skips and remove interpreter/compiler as necessary 324 326 325 // work files 327 326 $bName = Control::$outDir.basename($this->tptFileName, '.phpt'); 328 $this->testFileName = $bName.'.php'; 327 $this->testFileName = $bName.'.php'; 329 328 $this->expectFileName = $bName.'.expect'; 329 // build (compiles only) 330 330 $this->buildFileName = $bName.'.build.out'; 331 331 $this->buildErrFileName = $bName.'.build.err'; 332 // stdout 332 333 $this->ioutFileName = $bName.'.i.out'; 333 334 $this->coutFileName = $bName.'.c.out'; 335 $this->poutFileName = $bName.'.p.out'; 336 // stderr 334 337 $this->ierrFileName = $bName.'.i.err'; 335 338 $this->cerrFileName = $bName.'.c.err'; 339 $this->perrFileName = $bName.'.p.err'; 340 // diff 336 341 $this->idiffFileName = $bName.'.i.diff'; 337 342 $this->cdiffFileName = $bName.'.c.diff'; 343 $this->pdiffFileName = $bName.'.p.diff'; 338 344 339 345 } … … 357 363 protected function executeTest($type) { 358 364 359 if (Control::$parseOnly && !isset($this->sectionData['EXPECTPARSE'])) {360 $this->interpretResult = PHP_Test::RESULT_SKIP;361 $this->compileResult = PHP_Test::RESULT_SKIP;362 return;363 }364 365 365 if ($type == self::INTERPRETER) { 366 366 367 /* 368 if (defined('ROADSEND_PHP')) { 369 $cmd = Control::$rphpBinary.' -I '.dirname($this->tptFileName).' -f '.$this->testFileName; 370 } 371 else { 372 // XXX do zend command here 373 } 374 */ 375 if (Control::$parseOnly) { 376 $cmd = Control::$rphpABinary.' --dump-ast '.$this->testFileName; 377 } 378 else { 379 $cmd = Control::$rphpBinary.' -f '.$this->testFileName; 380 } 367 $cmd = Control::$rphpBinary.' -f '.$this->testFileName; 381 368 382 369 // setup output vars … … 385 372 $result =& $this->interpretResult; 386 373 $errFileName =& $this->ierrFileName; 374 375 } 376 elseif ($type == self::ANALYZER) { 377 378 $passes = trim($this->sectionData['PASSES']); 379 if (empty($passes)) { 380 $passes = 'dump-ast'; 381 } 382 $cmd = Control::$rphpABinary.' --passes='.$passes.' '.$this->testFileName; 383 384 // setup output vars 385 $output =& $this->pOutput; 386 $outFileName =& $this->poutFileName; 387 $result =& $this->parseResult; 388 $errFileName =& $this->perrFileName; 389 387 390 } 388 391 else { … … 428 431 if ($type == self::INTERPRETER) 429 432 $this->interpretResult = $result; 433 elseif ($type == self::ANALYZER) 434 $this->parseResult = $result; 430 435 else 431 436 $this->compileResult = $result; … … 439 444 440 445 // compare output 441 if ($expectType != 'EXPECT') 446 if ($expectType != 'EXPECT') { 442 447 $re_expect = trim($expectData); 448 } 449 443 450 switch ($this->expectType) { 451 case 'EXPECTPARSE': 444 452 case 'EXPECT': 445 453 if ($output != trim($expectData)) { … … 476 484 477 485 protected function getExpectData() { 478 479 if (($type == self::COMPILER) && (isset($this->sectionData['COMPILER:'.$this->expectType]))) { 480 $expectData = $this->sectionData['COMPILER:'.$this->expectType]; 481 } 482 elseif (Control::$parseOnly) { 483 $expectData = $this->sectionData['EXPECTPARSE']; 484 } 485 else { 486 $expectData = $this->sectionData[$this->expectType]; 487 } 488 489 return $expectData; 486 return $this->sectionData[$this->expectType]; 490 487 } 491 488 … … 497 494 $this->iDiffOutput = `$cmd`; 498 495 file_put_contents($this->idiffFileName, $this->iDiffOutput); 496 } 497 elseif ($type == self::ANALYZER) { 498 $cmd = 'diff '.$this->expectFileName.' '.$this->poutFileName; 499 Control::log(2, $cmd); 500 $this->pDiffOutput = `$cmd`; 501 file_put_contents($this->pdiffFileName, $this->pDiffOutput); 499 502 } 500 503 else { … … 579 582 $this->writeTest(); 580 583 581 echo "INTERPRETER: "; 582 Control::flush(); 583 584 // do interpreter test 585 $this->executeTest(self::INTERPRETER); 586 587 if ($this->interpretResult == self::RESULT_FAIL) { 588 $this->writeDiff(self::INTERPRETER); 589 } 590 591 switch ($this->interpretResult) { 592 case self::RESULT_PASS: 593 Control::colorMsg(Control::GREEN,"PASS "); 594 break; 595 case self::RESULT_FAIL: 596 Control::colorMsg(Control::RED,"FAIL "); 597 break; 598 case self::RESULT_SKIP: 599 Control::colorMsg(Control::BLUE,"SKIP "); 600 break; 601 } 584 if ($this->testTypes & self::INTERPRETER) { 585 echo "INTERPRETER: "; 586 Control::flush(); 587 588 // do interpreter test 589 $this->executeTest(self::INTERPRETER); 590 591 if ($this->interpretResult == self::RESULT_FAIL) { 592 $this->writeDiff(self::INTERPRETER); 593 } 594 595 switch ($this->interpretResult) { 596 case self::RESULT_PASS: 597 Control::colorMsg(Control::GREEN,"PASS "); 598 break; 599 case self::RESULT_FAIL: 600 Control::colorMsg(Control::RED,"FAIL "); 601 break; 602 case self::RESULT_SKIP: 603 Control::colorMsg(Control::BLUE,"SKIP "); 604 break; 605 } 606 } 607 608 if ($this->testTypes & self::ANALYZER) { 609 echo "PARSE: "; 610 Control::flush(); 611 612 // do interpreter test 613 $this->executeTest(self::ANALYZER); 614 615 if ($this->parseResult == self::RESULT_FAIL) { 616 $this->writeDiff(self::ANALYZER); 617 } 618 619 switch ($this->parseResult) { 620 case self::RESULT_PASS: 621 Control::colorMsg(Control::GREEN,"PASS "); 622 break; 623 case self::RESULT_FAIL: 624 Control::colorMsg(Control::RED,"FAIL "); 625 break; 626 case self::RESULT_SKIP: 627 Control::colorMsg(Control::BLUE,"SKIP "); 628 break; 629 } 630 } 602 631 603 632 // do compiled test 604 if ( Control::$doCompiled) {633 if ($this->testTypes & self::COMPILER) { 605 634 echo " BUILD: "; 606 635 Control::flush(); -
trunk/rphp-testsuite/re-tests/main/basic-literals.phpt
r921 r1044 29 29 30 30 ?> 31 --EXPECTPARSE--32 foo33 31 --EXPECT-- 34 32 NULL
