private void recordMachineInfo() { MachineInfo machineInfo = this.inspector.getJobStatus().getProperties().getReproductionBuggyBuild().getMachineInfo(); machineInfo.setNumberCPU(Runtime.getRuntime().availableProcessors()); machineInfo.setFreeMemory(Runtime.getRuntime().freeMemory()); machineInfo.setTotalMemory(Runtime.getRuntime().totalMemory()); }
private void computeMetricsOnCompleteRepo() { this.getLogger().debug("Compute the line of code of the project"); ProcessBuilder processBuilder = new ProcessBuilder("/bin/sh","-c",COMPUTE_TOTAL_CLOC) .directory(new File(this.getInspector().getRepoLocalPath())); try { Process p = processBuilder.start(); BufferedReader stdin = new BufferedReader(new InputStreamReader(p.getInputStream())); p.waitFor(); this.getLogger().debug("Get result from cloc process..."); String processReturn = ""; String line; while (stdin.ready() && (line = stdin.readLine()) != null) { processReturn += line; } Gson gson = new GsonBuilder().create(); JsonObject json = gson.fromJson(processReturn, JsonObject.class); int numberLines = 0; if (json != null && json.getAsJsonObject("Java") != null) { JsonObject java = json.getAsJsonObject("Java"); if (java.getAsJsonPrimitive("code") != null) { numberLines = java.getAsJsonPrimitive("code").getAsInt(); } } this.getInspector().getJobStatus().getProperties().getProjectMetrics().setNumberLines(numberLines); } catch (IOException | InterruptedException e) { this.getLogger().error("Error while computing metrics on source code of the whole repo.", e); } }
protected void initProperties() { this.getJobStatus().getProperties().setVersion("Checkstyle 0.1"); super.initProperties(); }
protected void initProperties() { this.getJobStatus().getProperties().setVersion("Bears 1.0"); super.initProperties(); }
@Override protected StepStatus businessExecute() { this.getLogger().debug("Writing file with properties..."); String filePath; if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) { filePath = this.getInspector().getRepoLocalPath() + File.separator + PROPERTY_FILENAME; } else { filePath = this.getInspector().getRepoLocalPath() + File.separator + PROPERTY_FILENAME_BEARS; } Gson gson = new GsonBuilder().setPrettyPrinting().registerTypeAdapter(Properties.class, new PropertiesSerializerAdapter()).create(); String jsonString = gson.toJson(this.getInspector().getJobStatus().getProperties()); File file = new File(filePath); try { if (!file.exists()) { file.createNewFile(); } OutputStreamWriter outputStream = new OutputStreamWriter(new FileOutputStream(file)); outputStream.write(jsonString); outputStream.flush(); outputStream.close(); this.getInspector().getJobStatus().addFileToPush(file.getName()); return StepStatus.buildSuccess(this); } catch (IOException e) { this.addStepError("An exception occurred when writing the following property file: " + file.getPath(), e); } return StepStatus.buildError(this, PipelineState.PROPERTY_FILE_NOT_WRITTEN); }
@Override public void serializeData(ProjectInspector inspector) { Gson gson = new GsonBuilder().registerTypeAdapter(Properties.class, new PropertiesSerializerAdapter()).create(); JsonObject element = (JsonObject)gson.toJsonTree(inspector.getJobStatus().getProperties()); Date reproductionDateBeginning = inspector.getJobStatus().getProperties().getReproductionBuggyBuild().getReproductionDateBeginning(); reproductionDateBeginning = reproductionDateBeginning == null ? new Date() : reproductionDateBeginning; this.addDate(element, "reproductionDate", reproductionDateBeginning);
private void computeMetricsOnSourceDirs(File[] dirs) { int numberSourceFiles = super.computeMetricsOnDirs(dirs); this.getInspector().getJobStatus().getProperties().getProjectMetrics().setNumberSourceFiles(numberSourceFiles); }
private void computeMetricsOnTestDirs(File[] dirs) { int numberTestFiles = super.computeMetricsOnDirs(dirs); this.getInspector().getJobStatus().getProperties().getProjectMetrics().setNumberTestFiles(numberTestFiles); }
@Override protected StepStatus businessExecute() { this.getLogger().debug("Computing project plugins..."); String mainPomPath = this.getPom(); List<Plugin> plugins = this.findPlugins(mainPomPath); if (plugins == null) { this.getLogger().info("No plugins was found."); return StepStatus.buildError(this, PipelineState.PLUGINSNOTCOMPUTED); } else if (plugins.size() == 0) { this.getLogger().info("No plugins was found."); } this.getInspector().getJobStatus().setPlugins(plugins); this.getInspector().getJobStatus().getProperties().getProjectMetrics().setNumberPlugins(plugins.size()); return StepStatus.buildSuccess(this); } }
public void execute() { List<AbstractStep> steps = this.inspector.getSteps(); this.getLogger().debug("----------------------------------------------------------------------"); this.getLogger().debug("STEP "+ (steps.indexOf(this) + 1)+"/"+ steps.size() +": "+this.name); this.getLogger().debug("----------------------------------------------------------------------"); this.dateBegin = new Date(); this.stepStatus = this.businessExecute(); this.dateEnd = new Date(); this.getLogger().debug("STEP STATUS: "+this.stepStatus); this.getLogger().debug("STEP DURATION: "+getDuration()+"s"); this.inspector.getJobStatus().addStepDuration(this.name, getDuration()); this.inspector.getJobStatus().addFreeMemoryByStep(this.name, Runtime.getRuntime().freeMemory()); ReproductionBuggyBuild reproductionBuggyBuild = this.inspector.getJobStatus().getProperties().getReproductionBuggyBuild(); reproductionBuggyBuild.addStep(this); this.inspector.getJobStatus().addStepStatus(this.stepStatus); this.shouldStop = this.shouldStop || (this.isBlockingStep() && !this.stepStatus.isSuccess()); if (!this.shouldStop) { this.getLogger().debug("EXECUTE NEXT STEP"); this.executeNextStep(); } else { this.getLogger().debug("TERMINATE PIPELINE"); this.terminatePipeline(); } }
@Override protected StepStatus businessExecute() { this.getLogger().debug("Computing project modules..."); String mainPomPath = this.getPom(); File[] modules = this.findModules(mainPomPath, true); if (modules == null || modules.length == 0) { this.getLogger().info("No module was computed."); return StepStatus.buildError(this, PipelineState.MODULESNOTCOMPUTED); } this.getInspector().getJobStatus().setModules(modules); this.getInspector().getJobStatus().getProperties().getProjectMetrics().setNumberModules(modules.length); return StepStatus.buildSuccess(this); } }
protected String getPom() { if (!pomLocationTested) { testPomLocation(); this.inspector.getJobStatus().getProperties().getReproductionBuggyBuild() .setProjectRootPomPath(this.inspector.getJobStatus().getPomDirPath() + File.separator + Utils.POM_FILE); } return this.inspector.getJobStatus().getPomDirPath() + File.separator + Utils.POM_FILE; }
@Override protected StepStatus businessExecute() { this.getLogger().debug("Computing classpath from incriminated module..."); String incriminatedModule = this.getInspector().getJobStatus().getFailingModulePath(); Properties properties = new Properties(); properties.setProperty("mdep.outputFile", CLASSPATH_FILENAME); String pomModule = incriminatedModule + File.separator + Utils.POM_FILE; String classpathFilePath = incriminatedModule + File.separator + CLASSPATH_FILENAME; if (this.runMavenGoal(pomModule, properties) != MavenHelper.MAVEN_SUCCESS) { this.addStepError("Error while computing classpath maven."); return StepStatus.buildError(this, PipelineState.CLASSPATHERROR); } // Only jars will be added in the classpath here, which is the number of libraries of the failing module this.addJarFilesToClassPath(classpathFilePath); this.getInspector().getJobStatus().getProperties().getProjectMetrics().setNumberLibrariesFailingModule(this.classPath.size()); this.checkJUnitInClasspath(); // Default "/target/classes" and "/target/test-classes" dirs are then added here this.addDefaultDirsToClassPath(incriminatedModule); this.getInspector().getJobStatus().setRepairClassPath(this.classPath); return StepStatus.buildSuccess(this); } }
getLogger().info("Get the following failing module path: " + failingModulePath); Properties properties = jobStatus.getProperties(); FailingClass failingClass = properties.getTests().addFailingClass(testSuite.getFullClassName()); failingClass.setNumberRunning(testSuite.getNumberOfTests() - testSuite.getNumberOfSkipped()); Properties properties = this.getInspector().getJobStatus().getProperties(); properties.getTests().getOverallMetrics().addFailure(typeTof.getFailureName(), typeTof.isError()); jobStatus.setFailureLocations(this.failureLocations); Properties properties = jobStatus.getProperties(); Tests tests = properties.getTests(); OverallMetrics overallMetrics = tests.getOverallMetrics();
PatchDiff patchDiff = jobStatus.getProperties().getPatchDiff(); patchDiff.getFiles().setNumberAdded(addedFiles.size()); patchDiff.getFiles().setNumberChanged(changedFiles.size());
public String createCommitMsg() { String commitMsg = ""; Commits commits = this.getInspector().getJobStatus().getProperties().getCommits(); Builds builds = this.getInspector().getJobStatus().getProperties().getBuilds(); switch (this.commitType) { case COMMIT_BUGGY_BUILD:
protected void initProperties() { try { Properties properties = this.jobStatus.getProperties();
Properties properties = jobStatus.getProperties(); Commit commit;