Search in sources :

Example 1 with ChangedSources

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

the class FastBuildChangedFilesServiceTest method unknownFilesAreIgnored_modifiedBeforeCompilationFinishes.

@Test
public void unknownFilesAreIgnored_modifiedBeforeCompilationFinishes() {
    SettableFuture<BuildOutput> buildOutput = SettableFuture.create();
    changedFilesService.newBuild(Label.create("//java:all_files"), buildOutput);
    workspace.createFile(WorkspacePath.createIfValid("One.java"));
    workspace.createFile(WorkspacePath.createIfValid("Three.java"));
    buildOutput.set(BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//java:all_files"), sources("One.java", "Two.java").build()), BLAZE_INFO));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).containsExactly(artifactLocationDecoder.decode(source("One.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 2 with ChangedSources

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

the class FastBuildChangedFilesServiceTest method graphOfLabels.

@Test
public void graphOfLabels() {
    // A--> B -> D
    // \
    // \-> C -> B -> D
    BuildOutput buildOutput = BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//a:a"), sources("a.java").setDependencies(deps("//b:b", "//c:c")).build(), Label.create("//b:b"), sources("b.java").setDependencies(deps("//d:d")).build(), Label.create("//c:c"), sources("c.java").setDependencies(deps("//b:b")).build(), Label.create("//d:d"), sources("d.java").build()), BLAZE_INFO);
    changedFilesService.newBuild(Label.create("//a:a"), Futures.immediateFuture(buildOutput));
    workspace.createFile(WorkspacePath.createIfValid("d.java"));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//a:a"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).containsExactly(artifactLocationDecoder.decode(source("d.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 3 with ChangedSources

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

the class FastBuildChangedFilesServiceTest method suggestsRecompilation_modifiedBeforeCompilationFinishes.

@Test
public void suggestsRecompilation_modifiedBeforeCompilationFinishes() {
    SettableFuture<BuildOutput> buildOutput = SettableFuture.create();
    changedFilesService.newBuild(Label.create("//java:all_files"), buildOutput);
    String[] filenames = new String[FastBuildChangedFilesService.MAX_FILES_TO_COLLECT + 1];
    Arrays.setAll(filenames, i -> "File" + i + ".java");
    Arrays.stream(filenames).map(WorkspacePath::createIfValid).forEach(workspace::createFile);
    buildOutput.set(BuildOutput.create(new File("deploy.jar"), ImmutableMap.of(Label.create("//java:all_files"), sources(filenames).build()), BLAZE_INFO));
    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 4 with ChangedSources

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

the class FastBuildChangedFilesServiceTest method unknownFilesAreIgnored.

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

Example 5 with ChangedSources

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

the class FastBuildChangedFilesServiceTest method successfulBuildWithNoSources.

@Test
public void successfulBuildWithNoSources() {
    changedFilesService.newBuild(Label.create("//java:all_files"), Futures.immediateFuture(BuildOutput.create(new File("deploy.jar"), /* blazeData= */
    ImmutableMap.of(), BLAZE_INFO)));
    ChangedSources changedSources = changedFilesService.getAndResetChangedSources(Label.create("//java:all_files"));
    assertThat(changedSources.needsFullCompile()).isFalse();
    assertThat(changedSources.changedSources()).isEmpty();
}
Also used : 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