示例#1
0
文件: Utility.php 项目: rixrix/agnos
 /**
  * Returns a canonical absolute path of the test file(s).
  *
  * This function validates if the file really exist or is not a directory 
  * 
  * @param   mixed   An array of $path or a string $path only.
  * @return  mixed   An array of $path or a string $path only.
  *  
  * @access  public  
  */
 public function setUpTestFile($filename)
 {
     if (is_array($filename)) {
         foreach ($filename as $file) {
             $fp = agnosFileDir::getFullPath($file);
             if (!agnosFileDir::isValidFile($fp)) {
                 agnosConsole::realTime("FATAL", "Invalid or file not found", $file);
                 return false;
             }
             $canonicalPath[] = $fp;
         }
         return $canonicalPath;
     } else {
         $fp = agnosFileDir::getFullPath($filename);
         if (agnosFileDir::isValidFile($fp)) {
             return $fp;
         }
     }
     agnosConsole::realTime("FATAL", "Invalid file found", $filename);
     return false;
 }
示例#2
0
文件: Tester.php 项目: rixrix/agnos
 /**
  * Runs the specified test file
  *
  * @param  string  Test file
  * @access public
  */
 public function testRun($testFile)
 {
     $ParseTestFile =& new agnosParser($testFile);
     $isParsed = $ParseTestFile->parse();
     if ($isParsed == true) {
         $coreInstance =& new agnosTesterFactory($testFile, $ParseTestFile);
         $tester =& $coreInstance->createCoreInstance();
         $this->testFilePath = $testFile;
         $this->parsedTestFile =& $ParseTestFile;
         $testDesc = trim($this->parsedTestFile->fileSection['TEST']);
         /* Check if we need to skip the test */
         if (!$this->testRunSkip($tester)) {
             switch ($tester->run()) {
                 case false:
                     /* Problem running our test file ? */
                     $isPass = '******';
                     break;
                 case true:
                 default:
                     $tester->testOutput = str_replace("\r\n", "\n", trim($tester->testOutput));
                     $isMatch = $this->isMatch($tester->testOutput);
                     switch ($isMatch) {
                         case true:
                             $isPass = '******';
                             break;
                         case false:
                             /* Expected output doesn't match with the actual output */
                             $isPass = '******';
                             break;
                     }
                     break;
             }
             /*
              * Record this failed test
              * @todo : better implementation
              */
             if ($isPass == 'FAIL') {
                 $this->setFailedTest('FAILED', $this->testFilePath, $tester->tempTestFiles, $this->parsedTestFile->fileSection);
             }
         } else {
             $isPass = '******';
             $this->setFailedTest('SKIPPED', $this->testFilePath, $tester->tempTestFiles, $this->parsedTestFile->fileSection);
         }
         /* Show info in console */
         agnosConsole::realTime($isPass, $testDesc, $testFile);
     } else {
         /*
          * Save the borked info properly
          */
         $this->setBorkedInformation($this->parsedTestFile->borkedInformations);
     }
     return false;
 }