diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 46b416f36c0..5489b73497f 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -622,36 +622,6 @@ standaloneTest('enumEquals') { flags = ['-XXLanguage:-ProhibitComparisonOfIncompatibleEnums', '-e', 'runtime.basic.enum_equals.main'] } -standaloneTest("entry0") { - useGoldenData = true - source = "runtime/basic/entry0.kt" - flags = ["-entry", "runtime.basic.entry0.main"] -} - -standaloneTest("entry1") { - useGoldenData = true - source = "runtime/basic/entry1.kt" - flags = ["-entry", "foo"] -} - -linkTest("entry2") { - useGoldenData = true - source = "runtime/basic/entry2.kt" - lib = "runtime/basic/libentry2.kt" - flags = ["-entry", "foo"] -} - -standaloneTest("entry3") { - useGoldenData = true - source = "runtime/basic/entry3.kt" - flags = ["-entry", "bar"] -} - -standaloneTest("entry4") { - useGoldenData = true - source = "runtime/basic/entry4.kt" -} - standaloneTest("cleaner_basic") { enabled = !isNoopGC source = "runtime/basic/cleaner_basic.kt" @@ -2365,12 +2335,6 @@ tasks.register("break1", KonanLocalTest) { source = "codegen/controlflow/break1.kt" } -standaloneTest("args0") { - arguments = ["AAA", "BB", "C"] - useGoldenData = true - source = "runtime/basic/args0.kt" -} - standaloneTest("devirtualization_lateinitInterface") { disabled = (cacheTesting != null) // Cache is not compatible with -opt. useGoldenData = true diff --git a/kotlin-native/backend.native/tests/runtime/basic/args0.kt b/kotlin-native/backend.native/tests/runtime/basic/args0.kt deleted file mode 100644 index 88b91bc1dc5..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/args0.kt +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -fun main(args : Array) { - for (s in args) { - println(s) - } -} diff --git a/kotlin-native/backend.native/tests/runtime/basic/args0.out b/kotlin-native/backend.native/tests/runtime/basic/args0.out deleted file mode 100644 index df417d65308..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/args0.out +++ /dev/null @@ -1,3 +0,0 @@ -AAA -BB -C diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry0.out b/kotlin-native/backend.native/tests/runtime/basic/entry0.out deleted file mode 100644 index 18832d35117..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry0.out +++ /dev/null @@ -1 +0,0 @@ -Hello. diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry1.kt b/kotlin-native/backend.native/tests/runtime/basic/entry1.kt deleted file mode 100644 index 53ba7d1b8a4..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry1.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -fun fail() { - println("Test failed, this is a wrong main() function.") -} - -fun foo(args: Array) { - println("Hello.") -} - -fun bar() { - println("Hello, without args.") -} - - -fun main(args: Array) { - fail() -} - diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry1.out b/kotlin-native/backend.native/tests/runtime/basic/entry1.out deleted file mode 100644 index 18832d35117..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry1.out +++ /dev/null @@ -1 +0,0 @@ -Hello. diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry2.kt b/kotlin-native/backend.native/tests/runtime/basic/entry2.kt deleted file mode 100644 index 9bc6bf7da6e..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry2.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -fun main(args: Array) { - fail() -} - diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry2.out b/kotlin-native/backend.native/tests/runtime/basic/entry2.out deleted file mode 100644 index 18832d35117..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry2.out +++ /dev/null @@ -1 +0,0 @@ -Hello. diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry3.kt b/kotlin-native/backend.native/tests/runtime/basic/entry3.kt deleted file mode 100644 index 53ba7d1b8a4..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry3.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -fun fail() { - println("Test failed, this is a wrong main() function.") -} - -fun foo(args: Array) { - println("Hello.") -} - -fun bar() { - println("Hello, without args.") -} - - -fun main(args: Array) { - fail() -} - diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry3.out b/kotlin-native/backend.native/tests/runtime/basic/entry3.out deleted file mode 100644 index a0874b3c043..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry3.out +++ /dev/null @@ -1 +0,0 @@ -Hello, without args. diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry4.kt b/kotlin-native/backend.native/tests/runtime/basic/entry4.kt deleted file mode 100644 index 2bb0ac9bd6f..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry4.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun main() { - println("This is main without args") -} diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry4.out b/kotlin-native/backend.native/tests/runtime/basic/entry4.out deleted file mode 100644 index da5cf725571..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/entry4.out +++ /dev/null @@ -1 +0,0 @@ -This is main without args diff --git a/kotlin-native/backend.native/tests/runtime/basic/libentry2.kt b/kotlin-native/backend.native/tests/runtime/basic/libentry2.kt deleted file mode 100644 index 4e70e2cd305..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/libentry2.kt +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -fun fail() { - println("Test failed, this is a wrong main() function.") -} - -fun foo(args: Array) { - println("Hello.") -} - diff --git a/native/native.tests/testData/standalone/entryPoint/args.kt b/native/native.tests/testData/standalone/entryPoint/args.kt new file mode 100644 index 00000000000..6a52d207f5e --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/args.kt @@ -0,0 +1,7 @@ +// PROGRAM_ARGS: AAA BB C + +import kotlin.test.* + +fun main(args: Array) { + assertContentEquals(arrayOf("AAA", "BB", "C"), args) +} \ No newline at end of file diff --git a/native/native.tests/testData/standalone/entryPoint/differentEntry.kt b/native/native.tests/testData/standalone/entryPoint/differentEntry.kt new file mode 100644 index 00000000000..4aa19a86b04 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/differentEntry.kt @@ -0,0 +1,20 @@ +// OUTPUT_DATA_FILE: differentEntry.out +// ENTRY_POINT: foo + +import kotlin.test.* + +fun foo() { + fail() +} + +fun foo(args: Array) { + println("OK") +} + +fun bar() { + fail() +} + +fun main(args: Array) { + fail() +} diff --git a/native/native.tests/testData/standalone/entryPoint/differentEntry.out b/native/native.tests/testData/standalone/entryPoint/differentEntry.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/differentEntry.out @@ -0,0 +1 @@ +OK diff --git a/native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.kt b/native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.kt new file mode 100644 index 00000000000..5f144f078ae --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.kt @@ -0,0 +1,18 @@ +// OUTPUT_DATA_FILE: differentEntryMultiModule.out +// ENTRY_POINT: foo + +// MODULE: lib +// FILE: lib.kt + +fun foo(args: Array) { + println("OK") +} + +// MODULE: program(lib) +// FILE: main.kt + +import kotlin.test.* + +fun main(args: Array) { + fail() +} \ No newline at end of file diff --git a/native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.out b/native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.out @@ -0,0 +1 @@ +OK diff --git a/native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.kt b/native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.kt new file mode 100644 index 00000000000..fd657f666f7 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.kt @@ -0,0 +1,20 @@ +// OUTPUT_DATA_FILE: differentEntry.out +// ENTRY_POINT: foo + +import kotlin.test.* + +fun foo() { + println("OK") +} + +fun foo(args: Array) { + fail() +} + +fun bar() { + fail() +} + +fun main(args: Array) { + fail() +} diff --git a/native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.out b/native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.out @@ -0,0 +1 @@ +OK diff --git a/kotlin-native/backend.native/tests/runtime/basic/entry0.kt b/native/native.tests/testData/standalone/entryPoint/mainOverloading.kt similarity index 50% rename from kotlin-native/backend.native/tests/runtime/basic/entry0.kt rename to native/native.tests/testData/standalone/entryPoint/mainOverloading.kt index c910222464c..e110dba6657 100644 --- a/kotlin-native/backend.native/tests/runtime/basic/entry0.kt +++ b/native/native.tests/testData/standalone/entryPoint/mainOverloading.kt @@ -1,13 +1,6 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ +// OUTPUT_DATA_FILE: mainOverloading.out -package runtime.basic.entry0 - -fun fail() { - println("Test failed, this is a wrong main() function.") -} +import kotlin.test.* fun main() { fail() @@ -32,6 +25,5 @@ class Foo { } fun main(args: Array) { - println("Hello.") -} - + println("OK") +} \ No newline at end of file diff --git a/native/native.tests/testData/standalone/entryPoint/mainOverloading.out b/native/native.tests/testData/standalone/entryPoint/mainOverloading.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/mainOverloading.out @@ -0,0 +1 @@ +OK diff --git a/native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt b/native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt new file mode 100644 index 00000000000..e033bddd54b --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt @@ -0,0 +1,25 @@ +// OUTPUT_DATA_FILE: mainOverloading.out + +import kotlin.test.* + +fun main() { + println("OK") +} + +fun main(args: Array) { + fail() +} + +fun main(args: Array) { + fail() +} + +fun main(args: Array, second_arg: Int) { + fail() +} + +class Foo { + fun main(args: Array) { + fail() + } +} \ No newline at end of file diff --git a/native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.out b/native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.out @@ -0,0 +1 @@ +OK diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeStandaloneTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeStandaloneTestGenerated.java index 76de8f20975..96a8f836f9c 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeStandaloneTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeStandaloneTestGenerated.java @@ -90,4 +90,55 @@ public class FirNativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest runTest("native/native.tests/testData/standalone/console/readlnOrNullEmpty.kt"); } } + + @Nested + @TestMetadata("native/native.tests/testData/standalone/entryPoint") + @TestDataPath("$PROJECT_ROOT") + @Tag("standalone") + @EnforcedProperty(property = ClassLevelProperty.TEST_KIND, propertyValue = "STANDALONE_NO_TR") + @UseStandardTestCaseGroupProvider() + @Tag("frontend-fir") + @FirPipeline() + public class EntryPoint { + @Test + public void testAllFilesPresentInEntryPoint() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/entryPoint"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("args.kt") + public void testArgs() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/args.kt"); + } + + @Test + @TestMetadata("differentEntry.kt") + public void testDifferentEntry() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/differentEntry.kt"); + } + + @Test + @TestMetadata("differentEntryMultiModule.kt") + public void testDifferentEntryMultiModule() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.kt"); + } + + @Test + @TestMetadata("differentEntryNoArgs.kt") + public void testDifferentEntryNoArgs() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.kt"); + } + + @Test + @TestMetadata("mainOverloading.kt") + public void testMainOverloading() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/mainOverloading.kt"); + } + + @Test + @TestMetadata("mainOverloadingNoArgs.kt") + public void testMainOverloadingNoArgs() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt"); + } + } } diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeStandaloneTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeStandaloneTestGenerated.java index f221f4ba1d0..a58e9d2e48d 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeStandaloneTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeStandaloneTestGenerated.java @@ -85,4 +85,53 @@ public class NativeStandaloneTestGenerated extends AbstractNativeBlackBoxTest { runTest("native/native.tests/testData/standalone/console/readlnOrNullEmpty.kt"); } } + + @Nested + @TestMetadata("native/native.tests/testData/standalone/entryPoint") + @TestDataPath("$PROJECT_ROOT") + @Tag("standalone") + @EnforcedProperty(property = ClassLevelProperty.TEST_KIND, propertyValue = "STANDALONE_NO_TR") + @UseStandardTestCaseGroupProvider() + public class EntryPoint { + @Test + public void testAllFilesPresentInEntryPoint() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/standalone/entryPoint"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("args.kt") + public void testArgs() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/args.kt"); + } + + @Test + @TestMetadata("differentEntry.kt") + public void testDifferentEntry() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/differentEntry.kt"); + } + + @Test + @TestMetadata("differentEntryMultiModule.kt") + public void testDifferentEntryMultiModule() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/differentEntryMultiModule.kt"); + } + + @Test + @TestMetadata("differentEntryNoArgs.kt") + public void testDifferentEntryNoArgs() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/differentEntryNoArgs.kt"); + } + + @Test + @TestMetadata("mainOverloading.kt") + public void testMainOverloading() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/mainOverloading.kt"); + } + + @Test + @TestMetadata("mainOverloadingNoArgs.kt") + public void testMainOverloadingNoArgs() throws Exception { + runTest("native/native.tests/testData/standalone/entryPoint/mainOverloadingNoArgs.kt"); + } + } }