Example #1
0
 function run_test($subject)
 {
     global $phc;
     $bundle = new AsyncBundle($this, $subject);
     $bundle->commands[0] = get_php_command_line($subject);
     $bundle->out_handlers[0] = "homogenize_output";
     $bundle->callbacks[0] = NULL;
     $commands = array();
     foreach (get_pass_list() as $pass) {
         $commands[] = $this->get_command_line($subject, $this->dump, $pass);
         if ($this->last_pass == $pass) {
             break;
         }
     }
     // A slightly different approach here. We add all the passes. As
     // soon as once succeeds, we pass the test. If none succeeds, the
     // fail.
     foreach ($commands as $command) {
         $bundle->commands[] = $command;
         $bundle->out_handlers[] = "homogenize_output";
         $bundle->callbacks[] = "check_output";
     }
     $bundle->final = "finish";
     $bundle->start();
 }
Example #2
0
 function get_long_command_line($subject, $last_pass)
 {
     $long_command = "";
     $prev_pass = NULL;
     $concatenator = "";
     foreach (get_pass_list() as $pass) {
         $long_command .= $concatenator . $this->get_command_line($pass, $subject);
         $subject = NULL;
         // we dont need it after the first one
         $concatenator = " | ";
         // we want to pipe  the commands together
         // dont always give the full list
         if ($pass == $last_pass) {
             break;
         }
     }
     return $long_command;
 }
Example #3
0
 function finish($bundle)
 {
     global $opt_debug;
     $expected_final_xml = $bundle->outs[0];
     $final_xml = $bundle->outs[1];
     if ($final_xml === $expected_final_xml) {
         $this->async_success($bundle);
     } else {
         $pass_string = "";
         if ($opt_debug) {
             $last_pass = end(get_pass_list());
             // find the failing part
             foreach (get_pass_list() as $pass) {
                 $command1 = $this->get_command_line($pass, $bundle->subject);
                 $command2 = $this->get_long_command_line($bundle->subject, $pass);
                 if (($result1 = complete_exec($command1)) !== ($result2 = complete_exec($command2))) {
                     $bundle->commands[2] = $command1;
                     list($bundle->outs[2], $bundle->errs[2], $bundle->exits[2]) = $result1;
                     $bundle->commands[3] = $command2;
                     list($bundle->outs[3], $bundle->errs[3], $bundle->exits[3]) = $result2;
                     $pass_string = " in pass '{$pass}'";
                     break;
                 }
             }
         }
         $this->async_failure("Final output doesnt match expected{$pass_string}", $bundle);
     }
 }