-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the basic jvm test to avoid timing out.
- Loading branch information
Corbin Smith
committed
Mar 6, 2020
1 parent
f25caba
commit f0ff3ab
Showing
4 changed files
with
191 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmAbiTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2020 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package io.bazel.kotlin.builder.tasks.jvm; | ||
|
||
import io.bazel.kotlin.builder.Deps; | ||
import io.bazel.kotlin.builder.KotlinJvmTestBuilder; | ||
import java.util.function.Consumer; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class KotlinBuilderJvmAbiTest { | ||
private static final KotlinJvmTestBuilder ctx = new KotlinJvmTestBuilder(); | ||
|
||
private static final Consumer<KotlinJvmTestBuilder.TaskBuilder> SETUP_NORMALIZATION_TEST_SOURCES = | ||
ctx -> { | ||
ctx.addSource("AClass.kt", "package something;\n" + "class AClass{}"); | ||
ctx.addSource("BClass.kt", "package something;\n" + "class BClass{}"); | ||
ctx.outputJar().outputSrcJar(); | ||
}; | ||
|
||
@Test | ||
public void testGeneratesAbiOnly() { | ||
Deps.Dep d = ctx.runCompileTask( | ||
c -> { | ||
c.addSource("AClass.kt", "package something;" + "class AClass{}"); | ||
c.addSource("AnotherClass.java", "package something;", "", "class AnotherClass{}"); | ||
c.outputAbiJar(); | ||
}); | ||
ctx.runCompileTask( | ||
c -> { | ||
c.addDirectDependencies(d); | ||
c.addSource("Dependent.kt", | ||
"package dep;", | ||
"import something.AClass", | ||
"class Dependent{}"); | ||
c.outputJar().outputSrcJar().outputJdeps(); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testGeneratesAbiJarSource() { | ||
ctx.runCompileTask( | ||
c -> { | ||
c.addSource("AClass.kt", "package something;" + "class AClass{}"); | ||
c.addSource("AnotherClass.java", "package something;", "", "class AnotherClass{}"); | ||
// declaring outputJdeps also asserts existance after compile. | ||
c.outputJar(); | ||
c.outputSrcJar(); | ||
c.outputJdeps(); | ||
c.outputAbiJar(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmJavaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright 2020 The Bazel Authors. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package io.bazel.kotlin.builder.tasks.jvm; | ||
|
||
import io.bazel.kotlin.builder.DirectoryType; | ||
import io.bazel.kotlin.builder.KotlinJvmTestBuilder; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
@RunWith(JUnit4.class) | ||
public class KotlinBuilderJvmJavaTest { | ||
private static final KotlinJvmTestBuilder ctx = new KotlinJvmTestBuilder(); | ||
|
||
@Test | ||
public void testSimpleMixedModeCompile() { | ||
ctx.runCompileTask( | ||
c -> { | ||
c.addSource( | ||
"AClass.kt", | ||
"package something;" + "class AClass{}" | ||
); | ||
c.addSource( | ||
"AnotherClass.java", | ||
"package something;", | ||
"", | ||
"class AnotherClass{}" | ||
); | ||
c.outputJar().outputSrcJar(); | ||
}); | ||
ctx.assertFilesExist( | ||
DirectoryType.CLASSES, "something/AClass.class", "something/AnotherClass.class"); | ||
} | ||
|
||
@Test | ||
public void testGeneratesJDeps() { | ||
ctx.runCompileTask( | ||
c -> { | ||
c.addSource("AClass.kt", "package something;" + "class AClass{}"); | ||
c.addSource("AnotherClass.java", "package something;", "", "class AnotherClass{}"); | ||
// declaring outputJdeps also asserts existence after compile. | ||
c.outputJar().outputSrcJar().outputJdeps(); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testMixedBiReferences() { | ||
ctx.runCompileTask( | ||
ctx -> { | ||
ctx.addSource( | ||
"AClass.java", | ||
"package a;", | ||
"", | ||
"import b.BClass;", | ||
"", | ||
"public class AClass {", | ||
" static BClass b = new BClass();", | ||
"}"); | ||
ctx.addSource( | ||
"BClass.kt", | ||
"package b", | ||
"", | ||
"import a.AClass", | ||
"", | ||
"class BClass() {", | ||
" val a = AClass()", | ||
"}"); | ||
ctx.outputSrcJar() | ||
.outputJar(); | ||
}); | ||
ctx.assertFilesExist(DirectoryType.CLASSES, "a/AClass.class", "b/BClass.class"); | ||
} | ||
|
||
@Test | ||
public void testCompileSingleJavaFile() { | ||
ctx.runCompileTask( | ||
(ctx) -> { | ||
ctx.addSource("AnotherClass.java", "package something;", "", "class AnotherClass{}"); | ||
ctx.outputSrcJar() | ||
.outputJar(); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testJavaErrorRendering() { | ||
ctx.runFailingCompileTaskAndValidateOutput( | ||
() -> | ||
ctx.runCompileTask( | ||
c -> { | ||
c.addSource("AClass.kt", "package something;" + "class AClass{}"); | ||
c.addSource("AnotherClass.java", "package something;", "", "class AnotherClass{"); | ||
c.outputJar().outputSrcJar(); | ||
}), | ||
lines -> assertThat(lines.get(0)).startsWith(ctx.toPlatform("sources/AnotherClass"))); | ||
} | ||
} |