public static String getPrettyPrintState(ProjectInspector inspector) { JobStatus jobStatus = inspector.getJobStatus(); if (inspector instanceof ProjectInspector4Bears) { ProjectInspector4Bears inspector4Bears = (ProjectInspector4Bears) inspector; if (inspector4Bears.isBug()) { return inspector4Bears.getBugType(); } else if (inspector4Bears.getJobStatus().isReproducedAsFail()) { return "BUG REPRODUCED"; } } if (jobStatus.isHasBeenPatched()) { return "PATCHED"; } if (jobStatus.isReproducedAsFail()) { return "test failure"; } List<StepStatus> stepStatuses = jobStatus.getStepStatuses(); for (int i = stepStatuses.size()-1; i >= 0; i--) { StepStatus stepStatus = stepStatuses.get(i); if (stepStatus.getStatus() == StepStatus.StatusKind.FAILURE) { return stepStatus.getDiagnostic(); } } return "UNKNOWN"; }
public String getRemoteBranchName() { return this.getRepoSlug().replace('/', '-') + '-' + this.getBuggyBuild().getId() + '-' + this.getPatchedBuild().getId(); }
public void run() { AbstractStep cloneRepo = new CloneRepository(this); if (this.getBuildToBeInspected().getStatus() == ScannedBuildStatus.FAILING_AND_PASSING) { cloneRepo.addNextStep(new CheckoutBuggyBuild(this, true, CheckoutBuggyBuild.class.getSimpleName()+"Candidate")) .addNextStep(new ComputeSourceDir(this, false, true)) .addNextStep(new CommitPatch(this, CommitType.COMMIT_HUMAN_PATCH)); } else { if (this.getBuildToBeInspected().getStatus() == ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES) { cloneRepo.addNextStep(new CheckoutPatchedBuild(this, true, CheckoutPatchedBuild.class.getSimpleName()+"Candidate")) .addNextStep(new ComputeSourceDir(this, true, true)) .addNextStep(new CommitPatch(this, CommitType.COMMIT_HUMAN_PATCH)); } else { this.logger.debug("The pair of builds " + this.getBuggyBuild().getId() + ", " + this.getPatchedBuild().getId() + " is not interesting."); return; .addNextStep(new PushProcessEnd(this)); cloneRepo.setDataSerializer(this.getSerializers()); cloneRepo.setNotifiers(this.getNotifiers()); cloneRepo.execute(); } catch (Exception e) { this.getJobStatus().addStepError("Unknown", e.getMessage()); this.logger.debug("Exception catch while executing steps: ", e);
ProjectInspector4Bears inspector4Bears = (ProjectInspector4Bears) inspector; if (!alreadyNotified && inspector4Bears.isBug()) { String slug = inspector.getRepoSlug(); String fixerBuildType = inspector4Bears.getBugType(); String subject = "Fixer build found: "+inspector.getPatchedBuild().getId()+" - "+slug;
if (this.getInspector().getJobStatus().getLastPushState() != PushState.NONE) { if (this.getInspector() instanceof ProjectInspector4Bears && !((ProjectInspector4Bears) this.getInspector()).isBug()) { this.getLogger().error("The reproduction of the bug and/or the patch failed. Step bypassed."); return StepStatus.buildSkipped(this, "The reproduction of the bug and/or the patch failed. Step bypassed.");
protected void initProperties() { this.getJobStatus().getProperties().setVersion("Bears 1.0"); super.initProperties(); }
private void mainProcess() { LOGGER.info("Start by getting the build (buildId: "+this.getConfig().getBuildId()+") with the following config: "+this.getConfig()); this.getBuildToBeInspected(); HardwareInfoSerializer hardwareInfoSerializer = new HardwareInfoSerializer(this.engines, this.getConfig().getRunId(), this.getConfig().getBuildId()+""); hardwareInfoSerializer.serialize(); List<AbstractDataSerializer> serializers = new ArrayList<>(); if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { serializers.add(new InspectorSerializer4Bears(this.engines)); } else { serializers.add(new InspectorSerializer(this.engines)); } serializers.add(new PropertiesSerializer(this.engines)); serializers.add(new InspectorTimeSerializer(this.engines)); serializers.add(new PipelineErrorSerializer(this.engines)); serializers.add(new PatchesSerializer(this.engines)); serializers.add(new ToolDiagnosticSerializer(this.engines)); ProjectInspector inspector; if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { inspector = new ProjectInspector4Bears(buildToBeInspected, this.getConfig().getWorkspacePath(), serializers, this.notifiers); } else if (this.getConfig().getLauncherMode() == LauncherMode.CHECKSTYLE) { inspector = new ProjectInspector4Checkstyle(buildToBeInspected, this.getConfig().getWorkspacePath(), serializers, this.notifiers); } else { inspector = new ProjectInspector(buildToBeInspected, this.getConfig().getWorkspacePath(), serializers, this.notifiers); } inspector.setPatchNotifier(this.patchNotifier); inspector.run(); LOGGER.info("Inspector is finished. The process will exit now."); System.exit(0); }
if (this.getInspector().getJobStatus().getLastPushState() != PushState.NONE) { if (this.getInspector() instanceof ProjectInspector4Bears && !((ProjectInspector4Bears) this.getInspector()).isBug()) { this.getLogger().error("The reproduction of the bug and/or the patch failed. Step bypassed."); this.setPushState(PushState.REPO_NOT_PUSHED);
private void terminatePipeline() { if (!this.inspector.isPipelineEnding()) { this.inspector.setPipelineEnding(true); this.recordMachineInfo(); if (this.inspector.getFinalStep() != null) { if ((!(this.getInspector() instanceof ProjectInspector4Bears) && // Repairnator this.getInspector().getJobStatus().isReproducedAsFail()) // A bug was reproduced || (this.getInspector() instanceof ProjectInspector4Bears && // Bears ((ProjectInspector4Bears) this.getInspector()).isBug())) { // A bug and its patch were reproduced this.inspector.getFinalStep().execute(); } else { if (this.getInspector() instanceof ProjectInspector4Bears) { this.getLogger().debug("FINAL STEPS SKIPPED: The reproduction of the bug and/or the patch failed."); } else { this.getLogger().debug("FINAL STEPS SKIPPED: The reproduction of the bug failed."); } // So the final push state is repo not pushed this.setPushState(PushState.REPO_NOT_PUSHED); } } this.serializeData(); this.cleanMavenArtifactsAndLocalRepo(); this.inspector.printPipelineEnd(); } }