JPS, -Xcommon-sources: write tests

This commit is contained in:
Sergey Rostov
2018-09-10 15:14:45 +03:00
parent 313c27859a
commit c8351c3da0
12 changed files with 107 additions and 0 deletions
@@ -578,6 +578,24 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
public void testAllFilesPresentInCustom() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("commonSourcesCompilerArg")
public void testCommonSourcesCompilerArg() throws Exception {
runTest("jps-plugin/testData/incremental/multiModule/multiplatform/custom/commonSourcesCompilerArg/");
}
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/custom/commonSourcesCompilerArg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class CommonSourcesCompilerArg extends AbstractIncrementalJpsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInCommonSourcesCompilerArg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/custom/commonSourcesCompilerArg"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("jps-plugin/testData/incremental/pureKotlin")
@@ -0,0 +1,7 @@
c [sourceSetHolder]
pJvm [compilationAndSourceSetHolder, jvm]
pJvm -> c [include]
pJs [compilationAndSourceSetHolder, js]
pJs -> c [include]
@@ -0,0 +1,5 @@
use @Optional in JS
remove @Optional from JS
use @Optional in JVM
remove @Optional from JVM
add another @Optional in Common module
@@ -0,0 +1,62 @@
================ Step #1 use @Optional in JS =================
Building c
Building pJs
Compiling files:
pJs/src/c.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
Declaration annotated with '@OptionalExpectation' can only be used in common module sources
================ Step #2 remove @Optional from JS =================
Building c
Building pJs
Exit code: NOTHING_DONE
------------------------------------------
Building pJvm
Exit code: NOTHING_DONE
------------------------------------------
================ Step #3 use @Optional in JVM =================
Building c
Building pJs
Exit code: NOTHING_DONE
------------------------------------------
Building pJvm
Compiling files:
pJvm/src/c.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
Declaration annotated with '@OptionalExpectation' can only be used in common module sources
================ Step #4 remove @Optional from JVM =================
Building c
Building pJs
Exit code: NOTHING_DONE
------------------------------------------
Building pJvm
Exit code: NOTHING_DONE
------------------------------------------
================ Step #5 add another @Optional in Common module =================
Building c
Building pJs
Compiling files:
c/src/b.kt
End of files
Exit code: OK
------------------------------------------
Building pJvm
Compiling files:
c/src/b.kt
End of files
Exit code: OK
------------------------------------------
@@ -0,0 +1,7 @@
@file:Suppress("EXPERIMENTAL_API_USAGE_ERROR")
@OptionalExpectation
expect annotation class Optional(val value: String)
@Optional("Foo")
class Foo
@@ -0,0 +1,2 @@
@Optional("Foo")
class Bar
@@ -0,0 +1,3 @@
// Should be an error: Declaration annotated with '@OptionalExpectation' can only be used in common module sources
@Optional("BarJs")
class BarJs
@@ -0,0 +1,3 @@
// Should be an error: Declaration annotated with '@OptionalExpectation' can only be used in common module sources
@Optional("BarJvm")
class BarJvm