Search in sources :

Example 1 with IntellijAspectTestFixture

use of com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture in project intellij by bazelbuild.

the class IntellijAspectTestFixtureBuilder method main.

public static void main(String[] args) {
    try {
        String paramsFile = args[0].substring(1);
        String fileContents = new String(Files.readAllBytes(Paths.get(paramsFile)), UTF_8);
        List<String> realArgs = Splitter.on('\n').splitToList(fileContents);
        IntellijAspectTestFixture.Builder builder = IntellijAspectTestFixture.newBuilder();
        String outputFilePath = realArgs.get(0);
        String[] aspectFiles = realArgs.get(1).split(":");
        builder.addAllTargets(parseTargets(aspectFiles));
        for (int i = 2; i < realArgs.size(); i += 2) {
            String name = realArgs.get(i);
            List<String> paths = Splitter.on(':').omitEmptyStrings().splitToList(realArgs.get(i + 1));
            builder.addOutputGroups(OutputGroup.newBuilder().setName(name).addAllFilePaths(paths).build());
        }
        IntellijAspectTestFixture result = builder.build();
        try (OutputStream outputStream = new FileOutputStream(outputFilePath)) {
            outputStream.write(result.toByteArray());
        }
    } catch (IOException e) {
        System.err.println(e.toString());
        System.exit(-1);
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IntellijAspectTestFixture(com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture) IOException(java.io.IOException)

Example 2 with IntellijAspectTestFixture

use of com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture in project intellij by bazelbuild.

the class CcBinaryTest method testCcBinary.

@Test
public void testCcBinary() throws Exception {
    IntellijAspectTestFixture testFixture = loadTestFixture(":simple_fixture");
    TargetIdeInfo target = findTarget(testFixture, ":simple");
    assertThat(target.getKindString()).isEqualTo("cc_binary");
    assertThat(target.hasCIdeInfo()).isTrue();
    assertThat(target.hasJavaIdeInfo()).isFalse();
    assertThat(target.hasAndroidIdeInfo()).isFalse();
    CIdeInfo cTargetIdeInfo = target.getCIdeInfo();
    assertThat(cTargetIdeInfo.getTargetCoptList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetDefineList()).isEmpty();
    assertThat(cTargetIdeInfo.getTargetIncludeList()).isEmpty();
    // Can't test for this because the cc code stuffs source artifacts into
    // the output group
    // assertThat(testFixture.getIntellijResolveFilesList()).isEmpty();
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-cpp")).contains(testRelative("simple.intellij-info.txt"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-generic")).isEmpty();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) CIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo) IntellijAspectTestFixture(com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture) Test(org.junit.Test) BazelIntellijAspectTest(com.google.idea.blaze.BazelIntellijAspectTest)

Example 3 with IntellijAspectTestFixture

use of com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture in project intellij by bazelbuild.

the class JavaBinaryTest method testJavaBinary.

@Test
public void testJavaBinary() throws Exception {
    IntellijAspectTestFixture testFixture = loadTestFixture(":foo_fixture");
    TargetIdeInfo binaryInfo = findTarget(testFixture, ":foo");
    assertThat(binaryInfo.getKindString()).isEqualTo("java_binary");
    assertThat(relativePathsForArtifacts(binaryInfo.getJavaIdeInfo().getSourcesList())).containsExactly(testRelative("FooMain.java"));
    assertThat(dependenciesForTarget(binaryInfo)).contains(dep(":foolib"));
    assertThat(binaryInfo.getJavaIdeInfo().getJarsList().stream().map(IntellijAspectTest::libraryArtifactToString).collect(toList())).containsExactly(jarString(testRelative("foo.jar"), null, testRelative("foo-src.jar")));
    assertThat(binaryInfo.getJavaIdeInfo().getMainClass()).isEqualTo("com.google.MyMainClass");
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-java")).containsAllOf(testRelative("foolib.java-manifest"), testRelative("foolib.intellij-info.txt"), testRelative("foo.java-manifest"), testRelative("foo.intellij-info.txt"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-resolve-java")).containsAllOf(testRelative("libfoolib.jar"), testRelative("libfoolib-hjar.jar"), testRelative("libfoolib-src.jar"), testRelative("foo.jar"), testRelative("foo-src.jar"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-compile-java")).containsExactly(testRelative("libfoolib.jar"), testRelative("foo.jar"));
    assertThat(binaryInfo.getJavaIdeInfo().getJdeps().getRelativePath()).isEqualTo(testRelative("foo.jdeps"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-generic")).isEmpty();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) IntellijAspectTestFixture(com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture) IntellijAspectTest(com.google.idea.blaze.aspect.IntellijAspectTest) Test(org.junit.Test) BazelIntellijAspectTest(com.google.idea.blaze.BazelIntellijAspectTest)

Example 4 with IntellijAspectTestFixture

use of com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture in project intellij by bazelbuild.

the class JavaTestTest method testJavaTest.

@Test
public void testJavaTest() throws Exception {
    IntellijAspectTestFixture testFixture = loadTestFixture(":footest_fixture");
    TargetIdeInfo testInfo = findTarget(testFixture, ":FooTest");
    assertThat(testInfo.getKindString()).isEqualTo("java_test");
    assertThat(relativePathsForArtifacts(testInfo.getJavaIdeInfo().getSourcesList())).containsExactly(testRelative("FooTest.java"));
    assertThat(testInfo.getJavaIdeInfo().getJarsList().stream().map(IntellijAspectTest::libraryArtifactToString).collect(toList())).containsExactly(jarString(testRelative("FooTest.jar"), null, testRelative("FooTest-src.jar")));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-java")).containsAllOf(testRelative("FooTest.java-manifest"), testRelative("FooTest.intellij-info.txt"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-resolve-java")).containsAllOf(testRelative("FooTest.jar"), testRelative("FooTest-src.jar"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-compile-java")).contains(testRelative("FooTest.jar"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-java")).containsAllOf(testRelative("FooTest.java-manifest"), testRelative("FooTest.intellij-info.txt"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-generic")).isEmpty();
    assertThat(testInfo.getJavaIdeInfo().getJdeps().getRelativePath()).isEqualTo(testRelative("FooTest.jdeps"));
    assertThat(testInfo.getTestInfo().getSize()).isEqualTo("large");
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) IntellijAspectTestFixture(com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture) IntellijAspectTest(com.google.idea.blaze.aspect.IntellijAspectTest) Test(org.junit.Test) BazelIntellijAspectTest(com.google.idea.blaze.BazelIntellijAspectTest)

Example 5 with IntellijAspectTestFixture

use of com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture in project intellij by bazelbuild.

the class PyBinaryTest method testPyBinary.

@Test
public void testPyBinary() throws Exception {
    IntellijAspectTestFixture testFixture = loadTestFixture(":simple_fixture");
    TargetIdeInfo target = findTarget(testFixture, ":simple");
    assertThat(target.getKindString()).isEqualTo("py_binary");
    assertThat(relativePathsForArtifacts(target.getPyIdeInfo().getSourcesList())).containsExactly(testRelative("simple.py"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-py")).containsExactly(testRelative("simple.intellij-info.txt"));
    assertThat(getOutputGroupFiles(testFixture, "intellij-info-generic")).isEmpty();
}
Also used : TargetIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo) IntellijAspectTestFixture(com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture) Test(org.junit.Test) BazelIntellijAspectTest(com.google.idea.blaze.BazelIntellijAspectTest)

Aggregations

IntellijAspectTestFixture (com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture)34 BazelIntellijAspectTest (com.google.idea.blaze.BazelIntellijAspectTest)33 Test (org.junit.Test)33 TargetIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo)32 IntellijAspectTest (com.google.idea.blaze.aspect.IntellijAspectTest)11 CIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CIdeInfo)5 Iterables (com.google.common.collect.Iterables)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 CToolchainIdeInfo (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.CToolchainIdeInfo)1 Dependency (com.google.devtools.intellij.ideinfo.IntellijIdeInfo.Dependency)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 RunWith (org.junit.runner.RunWith)1 JUnit4 (org.junit.runners.JUnit4)1