Search in sources :

Example 6 with ChangedSources

use of com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources in project intellij by bazelbuild.

the class FastBuildChangedFilesServiceTest method suggestsRecompilation.

@Test
public void suggestsRecompilation() {
    String[] filenames = new String[FastBuildChangedFilesService.MAX_FILES_TO_COLLECT + 1];
    Arrays.setAll(filenames, i -> "File" + i + ".java");
    BuildOutput buildOutput = BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//java:all_files"), sources(filenames).build()), BLAZE_INFO);
    changedFilesService.newBuild(Label.create("//java:all_files"), Futures.immediateFuture(buildOutput));
    Arrays.stream(filenames).map(WorkspacePath::createIfValid).forEach(workspace::createFile);
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isTrue();
}
Also used : BuildOutput(com.google.idea.blaze.java.fastbuild.FastBuildState.BuildOutput) ChangedSources(com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources) File(java.io.File) Test(org.junit.Test)

Example 7 with ChangedSources

use of com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources in project intellij by bazelbuild.

the class FastBuildChangedFilesServiceTest method addFilesFromFailedCompilation.

@Test
public void addFilesFromFailedCompilation() {
    changedFilesService.newBuild(Label.create("//java:all_files"), SettableFuture.create());
    changedFilesService.addFilesFromFailedCompilation(Label.create("//java:all_files"), ImmutableSet.of(new File("/foo/bar.txt"), new File("/what/fun.txt")));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).containsExactly(new File("/foo/bar.txt"), new File("/what/fun.txt"));
}
Also used : ChangedSources(com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources) File(java.io.File) Test(org.junit.Test)

Example 8 with ChangedSources

use of com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources in project intellij by bazelbuild.

the class FastBuildChangedFilesServiceTest method successfulBuildWithSingleModification.

@Test
public void successfulBuildWithSingleModification() {
    BuildOutput buildOutput = BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//java:all_files"), sources("java/com/google/Hello.java").build()), BLAZE_INFO);
    changedFilesService.newBuild(Label.create("//java:all_files"), Futures.immediateFuture(buildOutput));
    workspace.createFile(WorkspacePath.createIfValid("java/com/google/Hello.java"));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).containsExactly(artifactLocationDecoder.decode(source("java/com/google/Hello.java")));
}
Also used : BuildOutput(com.google.idea.blaze.java.fastbuild.FastBuildState.BuildOutput) ChangedSources(com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources) File(java.io.File) Test(org.junit.Test)

Example 9 with ChangedSources

use of com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources in project intellij by bazelbuild.

the class FastBuildChangedFilesServiceTest method getSourcesClearsModifiedList.

@Test
public void getSourcesClearsModifiedList() {
    BuildOutput buildOutput = BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//java:all_files"), sources("java/com/google/Hello.java").build()), BLAZE_INFO);
    changedFilesService.newBuild(Label.create("//java:all_files"), Futures.immediateFuture(buildOutput));
    workspace.createFile(WorkspacePath.createIfValid("java/com/google/Hello.java"));
    changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).isEmpty();
}
Also used : BuildOutput(com.google.idea.blaze.java.fastbuild.FastBuildState.BuildOutput) ChangedSources(com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources) File(java.io.File) Test(org.junit.Test)

Example 10 with ChangedSources

use of com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources in project intellij by bazelbuild.

the class FastBuildChangedFilesServiceTest method successfulBuildWithModificationBeforeCompileFinishes.

@Test
public void successfulBuildWithModificationBeforeCompileFinishes() {
    SettableFuture<BuildOutput> buildOutput = SettableFuture.create();
    changedFilesService.newBuild(Label.create("//java:all_files"), buildOutput);
    workspace.createFile(WorkspacePath.createIfValid("java/com/google/Hello.java"));
    buildOutput.set(BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//java:all_files"), sources("java/com/google/Hello.java").build()), BLAZE_INFO));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).containsExactly(artifactLocationDecoder.decode(source("java/com/google/Hello.java")));
}
Also used : BuildOutput(com.google.idea.blaze.java.fastbuild.FastBuildState.BuildOutput) ChangedSources(com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources) File(java.io.File) Test(org.junit.Test)

Aggregations

ChangedSources (com.google.idea.blaze.java.fastbuild.FastBuildChangedFilesService.ChangedSources)13 File (java.io.File)12 Test (org.junit.Test)12 BuildOutput (com.google.idea.blaze.java.fastbuild.FastBuildState.BuildOutput)9