Пример #1
0
    $reduce->set_checking_function("check_for_failure_string");
}
if ($opt_interpret) {
    $reduce->set_checking_function("check_against_interpreted");
}
$input = file_get_contents($filename);
// TODO: call this on the first instance
if ($opt_command != "") {
    // TODO use opt_command on the first instance
    // TODO: use --no-xml-attrs
    throw new Exception("TODO");
}
if ($opt_xml) {
    $result = $reduce->run_on_xml($input);
} else {
    $result = $reduce->run_on_php($input);
}
print "Writing reduced file to {$filename}.reduced\n";
file_put_contents("{$filename}.reduced", $result);
/*
 * Callbacks for reduce
 */
function myrun($command, $stdin = NULL)
{
    if ($stdin === NULL) {
        mydebug(2, "Running command: {$command}");
    } else {
        mydebug(2, "Running command with stdin: {$command}");
    }
    # complete_exec prints commands at opt_verbose = 1, but we want it at 2
    global $opt_verbose;
Пример #2
0
 function reduce_failure($reason, $bundle)
 {
     inst("reduce failure: {$reason}, {$bundle->subject}");
     global $phc;
     $subject = $bundle->subject;
     if (isset($this->is_special_reduction[$subject])) {
         // Found: we're already reducing, and the bug is kept in
         $this->reduction_result[$subject] = true;
     } else {
         // Start reducing
         try {
             $reduce = new Reduce();
             $this->reductions[$subject] = $reduce;
             $reduce->set_checking_function(array($this, "reduce_checking_function"));
             $reduce->set_run_command_function(array($this, "reduce_run_function"));
             $reduce->set_phc($phc);
             $reduce->set_debug_function(array($this, "reduce_debug_function"));
             // Get the file, and send it to the reducer
             $contents = file_get_contents($subject);
             if (!$reduce->has_syntax_errors($contents)) {
                 $final_contents = $reduce->run_on_php($contents);
                 file_put_contents("{$subject}.{$this->get_name()}_reduced", $final_contents);
             }
         } catch (ReduceException $e) {
             // There can be lots of reasons for this, many benign. Ignore it.
         }
         $this->mark_failure($bundle->subject, $bundle->commands, $bundle->outs, $bundle->errs, $bundle->exits, $reason);
     }
 }