private List<InputBuildId> readListOfBuildIds() { List<InputBuildId> result = new ArrayList<>(); File inputFile = new File(this.config.getInputPath()); try { BufferedReader reader = new BufferedReader(new FileReader(inputFile)); while (reader.ready()) { String line = reader.readLine().trim(); if (!line.isEmpty()) { String[] buildIds = line.split(Utils.COMMA+""); if (buildIds.length > 0) { long buggyBuildId = Long.parseLong(buildIds[0]); if (this.config.getLauncherMode() == LauncherMode.BEARS) { if (buildIds.length > 1) { long patchedBuildId = Long.parseLong(buildIds[1]); result.add(new InputBuildId(buggyBuildId, patchedBuildId)); } else { LOGGER.error("The build "+buggyBuildId+" will not be processed because there is no next build for it in the input file."); } } else { result.add(new InputBuildId(buggyBuildId)); } } } } reader.close(); } catch (IOException e) { throw new RuntimeException("Error while reading build ids from file: "+inputFile.getPath(),e); } return result; }
@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); }
if (this.repairnatorConfig.getLauncherMode() == LauncherMode.BEARS) { this.envValues.add("NEXT_BUILD_ID="+this.inputBuildId.getPatchedBuildId()); if (this.repairnatorConfig.isDebug()) { this.envValues.add("GITHUB_OAUTH="+RepairnatorConfig.getInstance().getGithubToken()); this.envValues.add("RUN_ID="+this.repairnatorConfig.getRunId()); this.envValues.add("REPAIR_MODE="+this.repairnatorConfig.getLauncherMode().name().toLowerCase()); this.envValues.add("PUSH_URL="+this.repairnatorConfig.getPushRemoteRepo()); this.envValues.add("MONGODB_HOST="+this.repairnatorConfig.getMongodbHost()); if (this.repairnatorConfig.getLauncherMode() == LauncherMode.REPAIR || this.repairnatorConfig.getLauncherMode() == LauncherMode.CHECKSTYLE) { this.envValues.add("REPAIR_TOOLS=" + StringUtils.join(this.repairnatorConfig.getRepairTools(), ","));
BufferedWriter writer = null; if (this.config.getLauncherMode() != LauncherMode.BEARS || !this.config.isBearsDelimiter()) { writer = new BufferedWriter(new FileWriter(outputPath)); if (this.config.getLauncherMode() == LauncherMode.BEARS && this.config.isBearsDelimiter()) { String statusPath = filePath + "_" + status.name() + extension; writer = new BufferedWriter(new FileWriter(statusPath)); if (this.config.getLauncherMode() == LauncherMode.REPAIR) { Launcher.LOGGER.info("Incriminated project and build: " + buildToBeInspected.getBuggyBuild().getRepository().getSlug() + ":" + buildToBeInspected.getBuggyBuild().getId()); writer.write(buildToBeInspected.getBuggyBuild().getId() + "");
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); }
envValues.add("BRANCH_NAME="+this.branchName); envValues.add("REPOSITORY="+this.repairnatorConfig.getRepository()); if (this.repairnatorConfig.getLauncherMode() == LauncherMode.REPAIR) { String humanPatchStr = this.repairnatorConfig.isHumanPatch() ? "--human-patch" : ""; envValues.add("HUMAN_PATCH="+humanPatchStr);
this.initConfig(arguments); if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) { this.checkToolsLoaded(jsap); this.checkNopolSolverPath(jsap);
private void serializeData() { if (serializers != null) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { this.getLogger().info("Serialize all data for the pair of builds " + this.getInspector().getBuggyBuild().getId() + ", " + this.getInspector().getPatchedBuild().getId()); } else { this.getLogger().info("Serialize all data for build: " + this.getInspector().getBuggyBuild().getId()); } for (AbstractDataSerializer serializer : this.serializers) { serializer.serializeData(this.inspector); } } }
if (optionalLog.isPresent()) { Log jobLog = optionalLog.get(); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.CHECKSTYLE ) { if (jobLog.getContent().contains("maven-checkstyle")) { LOGGER.info("Checkstyle has been found in repository "+repository.getSlug()+" (id: "+repositoryId+") build (id: "+masterBuild.getId()+"). The repo is now whitelisted.");
if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { Optional<Build> optionalBuildPatch = jTravis.build().fromId(this.getConfig().getNextBuildId()); if (!optionalBuildPatch.isPresent()) {
if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.slugs.add(repo.getSlug()); this.repositories.add(repo); if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS) { for (Job job : build.getJobs()) { RepairnatorConfig.getInstance().getJTravis().refresh(job);
private void printToStdout(Map<ScannedBuildStatus, List<BuildToBeInspected>> listOfBuilds) { for (ScannedBuildStatus status : ScannedBuildStatus.values()) { if (!listOfBuilds.get(status).isEmpty()) { if (this.config.isBearsDelimiter()) { System.out.println("[Status="+status.name()+"]"); } for (BuildToBeInspected buildToBeInspected : listOfBuilds.get(status)) { if (this.config.getLauncherMode() == LauncherMode.REPAIR) { Launcher.LOGGER.info("Incriminated project and build: " + buildToBeInspected.getBuggyBuild().getRepository().getSlug() + ":" + buildToBeInspected.getBuggyBuild().getId()); System.out.println(buildToBeInspected.getBuggyBuild().getId()); } else { Launcher.LOGGER.info("Incriminated project and pair of builds: " + buildToBeInspected.getBuggyBuild().getRepository().getSlug() + ":" + buildToBeInspected.getBuggyBuild().getId() + "" + Utils.COMMA + "" + buildToBeInspected.getPatchedBuild().getId()); System.out.println(buildToBeInspected.getBuggyBuild().getId() + "" + Utils.COMMA + "" + buildToBeInspected.getPatchedBuild().getId()); } } } } }
private void initAndRunRTScanner() { LOGGER.info("Init RTScanner..."); LOGGER.info("RTScanner mode : " + this.config.getLauncherMode()); String runId = this.config.getRunId(); HardwareInfoSerializer hardwareInfoSerializer = new HardwareInfoSerializer(this.engines, runId, "rtScanner"); hardwareInfoSerializer.serialize(); RTScanner rtScanner = new RTScanner(runId, this.engines); if (this.summaryNotifier != null) { rtScanner.setSummaryNotifier(this.summaryNotifier); } if (this.config.getDuration() != null && this.endProcessNotifier != null) { rtScanner.setEndProcessNotifier(this.endProcessNotifier); } if (this.config.getWhiteList() != null) { rtScanner.initWhiteListedRepository(this.config.getWhiteList()); } if (this.config.getBlackList() != null) { rtScanner.initBlackListedRepository(this.config.getBlackList()); } LOGGER.info("Start RTScanner..."); rtScanner.launch(); }
public BuildToBeInspected getBuildToBeInspected(Build build) { if (testBuild(build)) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.REPAIR) { this.logger.debug("Build "+build.getId()+" is interesting to be inspected."); return new BuildToBeInspected(build, null, ScannedBuildStatus.ONLY_FAIL, this.runId);
private Map<ScannedBuildStatus, List<BuildToBeInspected>> runScanner() throws IOException { Launcher.LOGGER.info("Start to scan projects in Travis..."); ProjectScanner scanner = new ProjectScanner(this.config.getLookFromDate(), this.config.getLookToDate(), this.config.getRunId()); Map<ScannedBuildStatus, List<BuildToBeInspected>> buildsToBeInspected = scanner.getListOfBuildsToBeInspectedFromProjects(this.config.getInputPath()); ProcessSerializer scannerSerializer; if (this.config.getLauncherMode() == LauncherMode.REPAIR) { scannerSerializer = new ScannerSerializer(this.engines, scanner); } else { scannerSerializer = new ScannerSerializer4Bears(this.engines, scanner); ScannerDetailedDataSerializer scannerDetailedDataSerializer = new ScannerDetailedDataSerializer(this.engines, buildsToBeInspected); scannerDetailedDataSerializer.serialize(); } scannerSerializer.serialize(); Launcher.LOGGER.info("---------------------------------------------------------------"); Launcher.LOGGER.info("Scanner results."); Launcher.LOGGER.info("---------------------------------------------------------------"); if (buildsToBeInspected.isEmpty()) { Launcher.LOGGER.info("No build interesting to be inspected has been found ("+scanner.getTotalScannedBuilds()+" scanned builds.)"); } else { Launcher.LOGGER.info(buildsToBeInspected.size()+" builds interesting to be inspected have been found ("+scanner.getTotalScannedBuilds()+" scanned builds.)"); } return buildsToBeInspected; }
@Override public StepStatus shouldBeStopped(GatherTestInformation gatherTestInformation) { ProjectInspector inspector = gatherTestInformation.getInspector(); if (gatherTestInformation.getNbFailingTests() + gatherTestInformation.getNbErroringTests() == 0 && gatherTestInformation.getNbRunningTests() > 0) { if (RepairnatorConfig.getInstance().getLauncherMode() == LauncherMode.BEARS && inspector instanceof ProjectInspector4Bears) { if (inspector.getBuildToBeInspected().getStatus() == ScannedBuildStatus.FAILING_AND_PASSING) { // So, 1) the current passing build can be reproduced and 2) its previous build is a failing build // with failing tests and it can also be reproduced ((ProjectInspector4Bears) inspector).setBug(true, PipelineState.BUG_FAILING_PASSING.name()); } else if (inspector.getBuildToBeInspected().getStatus() == ScannedBuildStatus.PASSING_AND_PASSING_WITH_TEST_CHANGES) { // So, 1) the current passing build can be reproduced and 2) its previous build is a passing build // that fails when tested with new tests and it can also be reproduced ((ProjectInspector4Bears) inspector).setBug(true, PipelineState.BUG_PASSING_PASSING.name()); } } return StepStatus.buildSuccess(gatherTestInformation); } if (gatherTestInformation.getNbRunningTests() == 0) { return StepStatus.buildError(gatherTestInformation, PipelineState.TESTERRORS); } else { return StepStatus.buildError(gatherTestInformation, PipelineState.TESTFAILURES); } }
if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { this.getConfig().setNextBuildId(arguments.getInt("nextBuild")); if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) { LOGGER.info("The following repair tools will be used: " + StringUtils.join(this.getConfig().getRepairTools(), ", "));
if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { commitMsg = "End of the bug and patch reproduction process"; } else {