Search in sources :

Example 6 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestProjectInspector method testRepairingWithNPEFix.

@Test
public void testRepairingWithNPEFix() throws IOException, GitAPIException {
    // surli/failingProject npe
    int buildId = 253130137;
    Path tmpDirPath = Files.createTempDirectory("test_complete_npe");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build failingBuild = BuildHelper.getBuildFromId(buildId, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, null, ScannedBuildStatus.ONLY_FAIL, "testnpe");
    List<AbstractDataSerializer> serializers = new ArrayList<>();
    List<AbstractNotifier> notifiers = new ArrayList<>();
    List<SerializerEngine> serializerEngines = new ArrayList<>();
    SerializerEngine serializerEngine = mock(SerializerEngine.class);
    serializerEngines.add(serializerEngine);
    List<NotifierEngine> notifierEngines = new ArrayList<>();
    NotifierEngine notifierEngine = mock(NotifierEngine.class);
    notifierEngines.add(notifierEngine);
    serializers.add(new InspectorSerializer(serializerEngines));
    serializers.add(new NopolSerializer(serializerEngines));
    notifiers.add(new PatchNotifier(notifierEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.REPAIR);
    ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getAstorStatus(), is(AstorOutputStatus.MAX_GENERATION));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.NOPOL_PATCHED));
    assertThat(jobStatus.getPushState(), is(PushState.REPAIR_INFO_COMMITTED));
    assertThat(jobStatus.getFailureLocations().size(), is(1));
    assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
    assertThat(jobStatus.isHasBeenPatched(), is(true));
    assertThat(jobStatus.getNpeFixPatches().size(), is(6));
    // Nopol and NPEFix
    verify(notifierEngine, times(2)).notify(anyString(), anyString());
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.NOPOL));
    Git gitDir = Git.open(new File(inspector.getRepoToPushLocalPath()));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    assertThat(iterator.hasNext(), is(true));
    RevCommit commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("End of the repairnator process"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Automatic repair"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : PatchNotifier(fr.inria.spirals.repairnator.notifier.PatchNotifier) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) ArrayList(java.util.ArrayList) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Path(java.nio.file.Path) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) Git(org.eclipse.jgit.api.Git) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Test(org.junit.Test)

Example 7 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestProjectInspector method testPatchFailingProjectM70.

@Ignore
@Test
public void testPatchFailingProjectM70() throws IOException, GitAPIException {
    // surli/failingProject only-one-failing
    int buildId = 269201915;
    Path tmpDirPath = Files.createTempDirectory("test_complete");
    File tmpDir = tmpDirPath.toFile();
    tmpDir.deleteOnExit();
    Build failingBuild = BuildHelper.getBuildFromId(buildId, null);
    BuildToBeInspected buildToBeInspected = new BuildToBeInspected(failingBuild, null, ScannedBuildStatus.ONLY_FAIL, "test");
    List<AbstractDataSerializer> serializers = new ArrayList<>();
    List<AbstractNotifier> notifiers = new ArrayList<>();
    List<SerializerEngine> serializerEngines = new ArrayList<>();
    SerializerEngine serializerEngine = mock(SerializerEngine.class);
    serializerEngines.add(serializerEngine);
    List<NotifierEngine> notifierEngines = new ArrayList<>();
    NotifierEngine notifierEngine = mock(NotifierEngine.class);
    notifierEngines.add(notifierEngine);
    serializers.add(new InspectorSerializer(serializerEngines));
    serializers.add(new NopolSerializer(serializerEngines));
    notifiers.add(new PatchNotifier(notifierEngines));
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setLauncherMode(LauncherMode.REPAIR);
    ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), serializers, notifiers);
    inspector.run();
    JobStatus jobStatus = inspector.getJobStatus();
    assertThat(jobStatus.getAstorStatus(), is(AstorOutputStatus.STOP_BY_PATCH_FOUND));
    assertThat(jobStatus.getPipelineState(), is(PipelineState.NOPOL_NOTPATCHED));
    assertThat(jobStatus.getPushState(), is(PushState.REPAIR_INFO_COMMITTED));
    assertThat(jobStatus.getFailureLocations().size(), is(1));
    assertThat(jobStatus.getMetrics().getFailureNames().size(), is(1));
    // notify for Astor, NPEFix and Nopol
    verify(notifierEngine, times(3)).notify(anyString(), anyString());
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.INSPECTOR));
    verify(serializerEngine, times(1)).serialize(anyListOf(SerializedData.class), eq(SerializerType.NOPOL));
    Git gitDir = Git.open(new File(inspector.getRepoToPushLocalPath()));
    Iterable<RevCommit> logs = gitDir.log().call();
    Iterator<RevCommit> iterator = logs.iterator();
    assertThat(iterator.hasNext(), is(true));
    RevCommit commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("End of the repairnator process"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Automatic repair"));
    commit = iterator.next();
    assertThat(commit.getShortMessage(), containsString("Bug commit"));
    assertThat(iterator.hasNext(), is(false));
}
Also used : PatchNotifier(fr.inria.spirals.repairnator.notifier.PatchNotifier) AbstractNotifier(fr.inria.spirals.repairnator.notifier.AbstractNotifier) ArrayList(java.util.ArrayList) AbstractDataSerializer(fr.inria.spirals.repairnator.serializer.AbstractDataSerializer) BuildToBeInspected(fr.inria.spirals.repairnator.BuildToBeInspected) Build(fr.inria.jtravis.entities.Build) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Path(java.nio.file.Path) RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) SerializerEngine(fr.inria.spirals.repairnator.serializer.engines.SerializerEngine) SerializedData(fr.inria.spirals.repairnator.serializer.engines.SerializedData) InspectorSerializer(fr.inria.spirals.repairnator.serializer.InspectorSerializer) Git(org.eclipse.jgit.api.Git) NotifierEngine(fr.inria.spirals.repairnator.notifier.engines.NotifierEngine) NopolSerializer(fr.inria.spirals.repairnator.serializer.NopolSerializer) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestProjectInspector4Bears method setUp.

@Before
public void setUp() {
    String solverPath;
    if (isMac()) {
        solverPath = SOLVER_PATH_DIR + SOLVER_NAME_MAC;
    } else {
        solverPath = SOLVER_PATH_DIR + SOLVER_NAME_LINUX;
    }
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setZ3solverPath(solverPath);
    config.setPush(true);
    config.setPushRemoteRepo("");
    Utils.setLoggersLevel(Level.ERROR);
}
Also used : RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Before(org.junit.Before)

Example 9 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class TestNopolRepair method setup.

@Before
public void setup() {
    String solverPath;
    if (isMac()) {
        solverPath = SOLVER_PATH_DIR + SOLVER_NAME_MAC;
    } else {
        solverPath = SOLVER_PATH_DIR + SOLVER_NAME_LINUX;
    }
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    config.setZ3solverPath(solverPath);
    Utils.setLoggersLevel(Level.ERROR);
}
Also used : RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) Before(org.junit.Before)

Example 10 with RepairnatorConfig

use of fr.inria.spirals.repairnator.config.RepairnatorConfig in project repairnator by Spirals-Team.

the class LauncherUtils method initSpreadsheetSerializerEngineWithFileSecret.

public static SerializerEngine initSpreadsheetSerializerEngineWithFileSecret(Logger logger) {
    RepairnatorConfig config = RepairnatorConfig.getInstance();
    if (config.getSpreadsheetId() != null && (new File(config.getGoogleSecretPath())).exists()) {
        logger.info("Initialize Google spreadsheet serializer engine.");
        GoogleSpreadSheetFactory.setSpreadsheetId(config.getSpreadsheetId());
        try {
            GoogleSpreadSheetFactory.initWithFileSecret(config.getGoogleSecretPath());
            return new GoogleSpreadsheetSerializerEngine();
        } catch (IOException | GeneralSecurityException e) {
            logger.error("Error while initializing Google Spreadsheet, no information will be serialized in spreadsheets.", e);
        }
    } else {
        logger.info("Google Spreadsheet won't be used for serialization.");
    }
    return null;
}
Also used : RepairnatorConfig(fr.inria.spirals.repairnator.config.RepairnatorConfig) GeneralSecurityException(java.security.GeneralSecurityException) GoogleSpreadsheetSerializerEngine(fr.inria.spirals.repairnator.serializer.engines.table.GoogleSpreadsheetSerializerEngine) IOException(java.io.IOException) File(java.io.File)

Aggregations

RepairnatorConfig (fr.inria.spirals.repairnator.config.RepairnatorConfig)19 File (java.io.File)12 Build (fr.inria.jtravis.entities.Build)11 BuildToBeInspected (fr.inria.spirals.repairnator.BuildToBeInspected)11 Path (java.nio.file.Path)11 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 SerializerEngine (fr.inria.spirals.repairnator.serializer.engines.SerializerEngine)8 Git (org.eclipse.jgit.api.Git)8 RevCommit (org.eclipse.jgit.revwalk.RevCommit)8 AbstractNotifier (fr.inria.spirals.repairnator.notifier.AbstractNotifier)7 AbstractDataSerializer (fr.inria.spirals.repairnator.serializer.AbstractDataSerializer)7 SerializedData (fr.inria.spirals.repairnator.serializer.engines.SerializedData)7 NotifierEngine (fr.inria.spirals.repairnator.notifier.engines.NotifierEngine)6 InspectorSerializer (fr.inria.spirals.repairnator.serializer.InspectorSerializer)5 NopolSerializer (fr.inria.spirals.repairnator.serializer.NopolSerializer)5 GitHelper (fr.inria.spirals.repairnator.process.git.GitHelper)4 JobStatus (fr.inria.spirals.repairnator.process.inspectors.JobStatus)4 ProjectInspector (fr.inria.spirals.repairnator.process.inspectors.ProjectInspector)4 CloneRepository (fr.inria.spirals.repairnator.process.step.CloneRepository)4