From 2442abadc379fd7fb7826ae957e3d7db4fa67db7 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Fri, 17 Apr 2020 12:37:11 +0300 Subject: [PATCH] Add test for KT-35957 --- ...latformJvmCompilerRunnerTestGenerated.java | 90 +++++++++++++------ .../kotlin/generators/tests/GenerateTests.kt | 1 + .../mpp/jvmOnly/multifilePartChanged/X.kt | 4 + .../jvmOnly/multifilePartChanged/build.log | 14 +++ .../jvmOnly/multifilePartChanged/commonX.kt | 5 ++ .../mpp/jvmOnly/multifilePartChanged/dummy.kt | 1 + .../multifilePartChanged/utilsActual.kt | 4 + .../multifilePartChanged/utilsActual.kt.new | 6 ++ .../multifilePartChanged/utilsNoActual.kt | 4 + 9 files changed, 101 insertions(+), 28 deletions(-) create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/X.kt create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/build.log create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/commonX.kt create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/dummy.kt create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt.new create mode 100644 jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsNoActual.kt diff --git a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalMultiplatformJvmCompilerRunnerTestGenerated.java b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalMultiplatformJvmCompilerRunnerTestGenerated.java index 021e22c58fa..5085cba0489 100644 --- a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalMultiplatformJvmCompilerRunnerTestGenerated.java +++ b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/IncrementalMultiplatformJvmCompilerRunnerTestGenerated.java @@ -16,51 +16,85 @@ import java.util.regex.Pattern; /** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@TestMetadata("jps-plugin/testData/incremental/mpp/allPlatforms") -@TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public class IncrementalMultiplatformJvmCompilerRunnerTestGenerated extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInAllPlatforms() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/allPlatforms"), Pattern.compile("^([^\\.]+)$"), null, true); - } - - @TestMetadata("touchActual") - public void testTouchActual() throws Exception { - runTest("jps-plugin/testData/incremental/mpp/allPlatforms/touchActual/"); - } - - @TestMetadata("touchExpect") - public void testTouchExpect() throws Exception { - runTest("jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect/"); - } - - @TestMetadata("jps-plugin/testData/incremental/mpp/allPlatforms/touchActual") + @TestMetadata("jps-plugin/testData/incremental/mpp/allPlatforms") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class TouchActual extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { + public static class AllPlatforms extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } - public void testAllFilesPresentInTouchActual() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/allPlatforms/touchActual"), Pattern.compile("^([^\\.]+)$"), null, true); + public void testAllFilesPresentInAllPlatforms() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/allPlatforms"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("touchActual") + public void testTouchActual() throws Exception { + runTest("jps-plugin/testData/incremental/mpp/allPlatforms/touchActual/"); + } + + @TestMetadata("touchExpect") + public void testTouchExpect() throws Exception { + runTest("jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect/"); + } + + @TestMetadata("jps-plugin/testData/incremental/mpp/allPlatforms/touchActual") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TouchActual extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTouchActual() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/allPlatforms/touchActual"), Pattern.compile("^([^\\.]+)$"), null, true); + } + } + + @TestMetadata("jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TouchExpect extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTouchExpect() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect"), Pattern.compile("^([^\\.]+)$"), null, true); + } } } - @TestMetadata("jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect") + @TestMetadata("jps-plugin/testData/incremental/mpp/jvmOnly") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class TouchExpect extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { + public static class JvmOnly extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } - public void testAllFilesPresentInTouchExpect() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/allPlatforms/touchExpect"), Pattern.compile("^([^\\.]+)$"), null, true); + public void testAllFilesPresentInJvmOnly() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/jvmOnly"), Pattern.compile("^([^\\.]+)$"), null, true); + } + + @TestMetadata("multifilePartChanged") + public void testMultifilePartChanged() throws Exception { + runTest("jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/"); + } + + @TestMetadata("jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultifilePartChanged extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInMultifilePartChanged() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged"), Pattern.compile("^([^\\.]+)$"), null, true); + } } } } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index a52f4fe6673..69fd467e6e6 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1297,6 +1297,7 @@ fun main(args: Array) { testClass { model("incremental/mpp/allPlatforms", extension = null, excludeParentDirs = true) + model("incremental/mpp/jvmOnly", extension = null, excludeParentDirs = true) } testClass { model("incremental/mpp/allPlatforms", extension = null, excludeParentDirs = true) diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/X.kt b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/X.kt new file mode 100644 index 00000000000..e47e8dbdb7d --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/X.kt @@ -0,0 +1,4 @@ +actual class X { + actual fun foo(): Any = 0 + fun bar(): Any = 1 +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/build.log b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/build.log new file mode 100644 index 00000000000..5cec33fd7c5 --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/build.log @@ -0,0 +1,14 @@ +================ Step #1 ================= + +Compiling files: + src/X.kt + src/commonX.kt + src/utilsActual.kt + src/utilsNoActual.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Class 'X' has several compatible actual declarations in modules , +Function 'foo' has several compatible actual declarations in modules , +Function 'useX' has several compatible actual declarations in modules , \ No newline at end of file diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/commonX.kt b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/commonX.kt new file mode 100644 index 00000000000..14468f025b7 --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/commonX.kt @@ -0,0 +1,5 @@ +expect class X { + fun foo(): Any +} + +expect fun useX(x: X): Any \ No newline at end of file diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/dummy.kt b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/dummy.kt new file mode 100644 index 00000000000..3f0c1c77242 --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/dummy.kt @@ -0,0 +1 @@ +fun dummy() {} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt new file mode 100644 index 00000000000..fa048f3f576 --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt @@ -0,0 +1,4 @@ +@file:JvmMultifileClass +@file:JvmName("Utils") + +actual fun useX(x: X): Any = x.foo() \ No newline at end of file diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt.new b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt.new new file mode 100644 index 00000000000..eda951b5556 --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsActual.kt.new @@ -0,0 +1,6 @@ +@file:JvmMultifileClass +@file:JvmName("Utils") + +actual fun useX(x: X): Any = x.foo() + +fun newFun() = 1 \ No newline at end of file diff --git a/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsNoActual.kt b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsNoActual.kt new file mode 100644 index 00000000000..c58549d42e4 --- /dev/null +++ b/jps-plugin/testData/incremental/mpp/jvmOnly/multifilePartChanged/utilsNoActual.kt @@ -0,0 +1,4 @@ +@file:JvmMultifileClass +@file:JvmName("Utils") + +fun useXBar(x: X) = x.bar() \ No newline at end of file