PythonNature nature = PythonNature.getPythonNature(container);
if (nature == null) {
throw new RuntimeException("The directory passed: " + container
+ " does not have an associated nature.");
}
AbstractRunner runner = UniversalRunner.getRunner(nature);
//First, combine the results of the many runs we may have.
Tuple<String, String> output = runner.runScriptAndGetOutput(PythonRunnerConfig.getCoverageScript(),
new String[] { "combine" }, getCoverageDirLocation(), monitor);
if (output.o1 != null && output.o1.length() > 0) {
Log.logInfo(output.o1);
}
if (output.o2 != null && output.o2.length() > 0) {
if (output.o2.startsWith("Coverage.py warning:")) {
Log.logInfo(output.o2);
} else {
Log.log(output.o2);
}
}
//we have to make a process to execute the script. it should look
// like:
//coverage.py -r [-m] FILE1 FILE2 ...
//Report on the statement coverage for the given files. With the -m
//option, show line numbers of the statements that weren't
// executed.
//python coverage.py -r -m files....
monitor.setTaskName("Starting shell to get info...");
monitor.worked(1);
Process p = null;
try {
// Tuple<Process, String> tup = runner.createProcess(
// PythonRunnerConfig.getCoverageScript(), new String[]{
// "-r", "-m", "--include", ".*"}, getCoverageDirLocation(), monitor);
Tuple<Process, String> tup = runner.createProcess(PythonRunnerConfig.getCoverageScript(),
new String[] { "--pydev-analyze" }, getCoverageDirLocation(), monitor);
p = tup.o1;
try {
p.exitValue();
throw new RuntimeException("Some error happened... the process could not be created.");