public function epvAction(Request $request)
 {
     $templateVariables = array();
     $github = $request->request->get('github');
     $debug = $request->request->get('debug');
     if ($github) {
         $results = $this->getDoctrine()->getRepository('AppBundle:EpvResults')->findByGithub($github);
         $em = $this->getDoctrine()->getManager();
         $fail = false;
         if ($results && sizeof($results)) {
             /** @var  $item EpvResults */
             foreach ($results as $item) {
                 if ($item->getRuntime() > time() - 30) {
                     $fail = true;
                 } else {
                     $em->remove($item);
                 }
             }
         }
         if (!$fail) {
             $int_output = new HtmlOutput();
             $output = new Output($int_output, $debug);
             $test = new TestStartup($output, TestStartup::TYPE_GITHUB, $github, $debug);
             $templateVariables['results'] = $int_output->getBuffer();
             $result = new EpvResults();
             $result->setGithub($github);
             $result->setRuntime(time());
             $em->persist($result);
             $em->flush();
         } else {
             $templateVariables['errors'] = 'Please wait a while before running EPV again.';
         }
     }
     return $this->render('AppBundle:Extensions:epv.html.twig', $templateVariables);
 }
Пример #2
0
 /**
  * Run prevalidator.
  *
  * @param string $directory		Directory where extracted revision is located
  * @return string
  */
 public function run_epv($directory)
 {
     $int_output = new HtmlOutput(HtmlOutput::TYPE_BBCODE);
     $output = new Output($int_output, false);
     $runner = new TestRunner($output, $directory, false, true);
     $runner->runTests();
     // Write a empty line
     $output->writeLn('');
     $found_msg = ' ';
     $found_msg .= 'Fatal: ' . $output->getMessageCount(Output::FATAL);
     $found_msg .= ', Error: ' . $output->getMessageCount(Output::ERROR);
     $found_msg .= ', Warning: ' . $output->getMessageCount(Output::WARNING);
     $found_msg .= ', Notice: ' . $output->getMessageCount(Output::NOTICE);
     $found_msg .= ' ';
     if ($output->getMessageCount(Output::FATAL) > 0 || $output->getMessageCount(Output::ERROR) > 0 || $output->getMessageCount(Output::WARNING) > 0) {
         $output->writeln('<fatal>' . str_repeat(' ', strlen($found_msg)) . '</fatal>');
         $output->writeln('<fatal> Validation: [b][color=#A91F1F]FAILED[/color][/b]' . str_repeat(' ', strlen($found_msg) - 19) . '</fatal>');
         $output->writeln('<fatal>' . $found_msg . '</fatal>');
         $output->writeln('<fatal>' . str_repeat(' ', strlen($found_msg)) . '</fatal>');
         $output->writeln('');
     } else {
         $output->writeln('<success>PASSED: ' . $found_msg . '</success>');
     }
     $output->writeln("<info>Test results for extension:</info>");
     $messages = $output->getMessages();
     if (!empty($messages)) {
         $output->writeln('[list]');
     }
     foreach ($messages as $msg) {
         $output->writeln('[*]' . (string) $msg);
     }
     if (!empty($messages)) {
         $output->writeln('[/list]');
     } else {
         $output->writeln("<success>[color=#00BF40]No issues found[/color] </success>");
     }
     return $int_output->getBuffer();
 }