Move JS tests generator to :js:js.tests, run it in "Generate Compiler Tests"
Also cleanup generateTestDataForReservedWords and make everything there private
This commit is contained in:
+2
-1
@@ -10,7 +10,8 @@
|
|||||||
</option>
|
</option>
|
||||||
<option name="taskNames">
|
<option name="taskNames">
|
||||||
<list>
|
<list>
|
||||||
<option value="generateTests" />
|
<option value=":compiler:generateTests" />
|
||||||
|
<option value=":js:js.tests:generateTests" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
<option name="vmOptions" value="" />
|
<option name="vmOptions" value="" />
|
||||||
|
|||||||
@@ -1130,63 +1130,4 @@ fun main(args: Array<String>) {
|
|||||||
model("android", recursive = false, extension = null)
|
model("android", recursive = false, extension = null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: repair these tests
|
|
||||||
//generateTestDataForReservedWords()
|
|
||||||
|
|
||||||
testGroup("js/js.tests/test", "js/js.translator/testData") {
|
|
||||||
testClass<AbstractBoxJsTest> {
|
|
||||||
model("box/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractSourceMapGenerationSmokeTest> {
|
|
||||||
model("sourcemap/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractOutputPrefixPostfixTest> {
|
|
||||||
model("outputPrefixPostfix/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractDceTest> {
|
|
||||||
model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractJsLineNumberTest> {
|
|
||||||
model("lineNumbers/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testGroup("js/js.tests/test", "compiler/testData") {
|
|
||||||
testClass<AbstractJsCodegenBoxTest> {
|
|
||||||
model("codegen/box", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractNonLocalReturnsTest> {
|
|
||||||
model("codegen/boxInline/nonLocalReturns/", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractPropertyAccessorsInlineTests> {
|
|
||||||
model("codegen/boxInline/property/", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractNoInlineTests> {
|
|
||||||
model("codegen/boxInline/noInline/", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractCallableReferenceInlineTests> {
|
|
||||||
model("codegen/boxInline/callableReference/", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractEnumValuesInlineTests> {
|
|
||||||
model("codegen/boxInline/enum/", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractInlineDefaultValuesTests> {
|
|
||||||
model("codegen/boxInline/defaultValues/", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractJsLegacyPrimitiveArraysBoxTest> {
|
|
||||||
model("codegen/box/arrays", targetBackend = TargetBackend.JS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ dependencies {
|
|||||||
testCompile(project(":js:js.dce"))
|
testCompile(project(":js:js.dce"))
|
||||||
testCompile(ideaSdkDeps("openapi", "idea", "idea_rt"))
|
testCompile(ideaSdkDeps("openapi", "idea", "idea_rt"))
|
||||||
testCompile(commonDep("junit:junit"))
|
testCompile(commonDep("junit:junit"))
|
||||||
|
testCompile(projectTests(":kotlin-build-common"))
|
||||||
|
testCompile(projectTests(":generators:test-generator"))
|
||||||
testRuntime(projectDist(":kotlin-compiler"))
|
testRuntime(projectDist(":kotlin-compiler"))
|
||||||
testRuntime(projectDist(":kotlin-stdlib"))
|
testRuntime(projectDist(":kotlin-stdlib"))
|
||||||
testRuntime(projectDist(":kotlin-stdlib-js"))
|
testRuntime(projectDist(":kotlin-stdlib-js"))
|
||||||
@@ -20,7 +22,6 @@ dependencies {
|
|||||||
testRuntime(projectDist(":kotlin-preloader")) // it's required for ant tests
|
testRuntime(projectDist(":kotlin-preloader")) // it's required for ant tests
|
||||||
testRuntime(project(":compiler:backend-common"))
|
testRuntime(project(":compiler:backend-common"))
|
||||||
testRuntime(commonDep("org.fusesource.jansi", "jansi"))
|
testRuntime(commonDep("org.fusesource.jansi", "jansi"))
|
||||||
testCompile(projectTests(":kotlin-build-common"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -49,3 +50,5 @@ projectTest("quickTest") {
|
|||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
systemProperty("kotlin.js.skipMinificationTest", "true")
|
systemProperty("kotlin.js.skipMinificationTest", "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateJsTestsKt")
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* 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 org.jetbrains.kotlin.generators.tests
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.generators.tests.generator.testGroup
|
||||||
|
import org.jetbrains.kotlin.js.test.AbstractDceTest
|
||||||
|
import org.jetbrains.kotlin.js.test.AbstractJsLineNumberTest
|
||||||
|
import org.jetbrains.kotlin.js.test.semantics.*
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
System.setProperty("java.awt.headless", "true")
|
||||||
|
|
||||||
|
// TODO: repair these tests
|
||||||
|
//generateTestDataForReservedWords()
|
||||||
|
|
||||||
|
testGroup("js/js.tests/test", "js/js.translator/testData") {
|
||||||
|
testClass<AbstractBoxJsTest> {
|
||||||
|
model("box/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractSourceMapGenerationSmokeTest> {
|
||||||
|
model("sourcemap/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractOutputPrefixPostfixTest> {
|
||||||
|
model("outputPrefixPostfix/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractDceTest> {
|
||||||
|
model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractJsLineNumberTest> {
|
||||||
|
model("lineNumbers/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testGroup("js/js.tests/test", "compiler/testData") {
|
||||||
|
testClass<AbstractJsCodegenBoxTest> {
|
||||||
|
model("codegen/box", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractNonLocalReturnsTest> {
|
||||||
|
model("codegen/boxInline/nonLocalReturns/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractPropertyAccessorsInlineTests> {
|
||||||
|
model("codegen/boxInline/property/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractNoInlineTests> {
|
||||||
|
model("codegen/boxInline/noInline/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractCallableReferenceInlineTests> {
|
||||||
|
model("codegen/boxInline/callableReference/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractEnumValuesInlineTests> {
|
||||||
|
model("codegen/boxInline/enum/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractInlineDefaultValuesTests> {
|
||||||
|
model("codegen/boxInline/defaultValues/", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
|
||||||
|
testClass<AbstractJsLegacyPrimitiveArraysBoxTest> {
|
||||||
|
model("codegen/box/arrays", targetBackend = TargetBackend.JS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
-32
@@ -22,9 +22,9 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
|||||||
import org.jetbrains.kotlin.renderer.KeywordStringsGenerated
|
import org.jetbrains.kotlin.renderer.KeywordStringsGenerated
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
val MODIFIER_KEYWORDS = KtTokens.MODIFIER_KEYWORDS_ARRAY.map { it.value }.toSet()
|
private val MODIFIER_KEYWORDS = KtTokens.MODIFIER_KEYWORDS_ARRAY.map { it.value }.toSet()
|
||||||
|
|
||||||
val commonCases: CaseBuilder.(String, String) -> Unit = { testByName, testByRef ->
|
private val commonCases: CaseBuilder.(String, String) -> Unit = { testByName, testByRef ->
|
||||||
case("val", "val $KEYWORD_MARKER: Int", " = 0", testByName)
|
case("val", "val $KEYWORD_MARKER: Int", " = 0", testByName)
|
||||||
case("var", "var $KEYWORD_MARKER: Int", " = 0", testByName)
|
case("var", "var $KEYWORD_MARKER: Int", " = 0", testByName)
|
||||||
case("fun", "fun $KEYWORD_MARKER()", " { $KEYWORD_MARKER() }", testByRef)
|
case("fun", "fun $KEYWORD_MARKER()", " { $KEYWORD_MARKER() }", testByRef)
|
||||||
@@ -37,13 +37,13 @@ val commonCases: CaseBuilder.(String, String) -> Unit = { testByName, testByRef
|
|||||||
case("label", "val t: Int", " = 0", "testRenamed(\"$KEYWORD_MARKER\", { $KEYWORD_MARKER@ while (false) {} })")
|
case("label", "val t: Int", " = 0", "testRenamed(\"$KEYWORD_MARKER\", { $KEYWORD_MARKER@ while (false) {} })")
|
||||||
}
|
}
|
||||||
|
|
||||||
val commonCasesWithTestNotRenamed: CaseBuilder.() -> Unit = { commonCases(testNotRenamedByName, testNotRenamedByRef) }
|
private val commonCasesWithTestNotRenamed: CaseBuilder.() -> Unit = { commonCases(testNotRenamedByName, testNotRenamedByRef) }
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
generateTestDataForReservedWords()
|
generateTestDataForReservedWords()
|
||||||
}
|
}
|
||||||
|
|
||||||
val TEST_DATA_DIR_FOR_RESERVED_WORDS = "js/js.translator/testData/box/reservedWords"
|
private val TEST_DATA_DIR_FOR_RESERVED_WORDS = "js/js.translator/testData/box/reservedWords"
|
||||||
|
|
||||||
fun generateTestDataForReservedWords() {
|
fun generateTestDataForReservedWords() {
|
||||||
generate(TEST_DATA_DIR_FOR_RESERVED_WORDS) {
|
generate(TEST_DATA_DIR_FOR_RESERVED_WORDS) {
|
||||||
@@ -158,7 +158,7 @@ fun box(): String {
|
|||||||
) {
|
) {
|
||||||
case("val", "val $KEYWORD_MARKER", "", testNotRenamedByName)
|
case("val", "val $KEYWORD_MARKER", "", testNotRenamedByName)
|
||||||
case("var", "var $KEYWORD_MARKER", "", testNotRenamedByName)
|
case("var", "var $KEYWORD_MARKER", "", testNotRenamedByName)
|
||||||
case("param", "$KEYWORD_MARKER", "", testRenamedByName, ignore = true)
|
case("param", KEYWORD_MARKER, "", testRenamedByName, ignore = true)
|
||||||
}
|
}
|
||||||
// -------------------------
|
// -------------------------
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ fun box(): String {
|
|||||||
|
|
||||||
// DSL
|
// DSL
|
||||||
|
|
||||||
class Case(
|
private class Case(
|
||||||
val name: String,
|
val name: String,
|
||||||
val testDeclaration: String,
|
val testDeclaration: String,
|
||||||
val testDeclarationInit: String,
|
val testDeclarationInit: String,
|
||||||
@@ -232,13 +232,13 @@ class Case(
|
|||||||
val additionalShouldBeEscaped: Set<String>
|
val additionalShouldBeEscaped: Set<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
class Suite(
|
private class Suite(
|
||||||
val name: String,
|
val name: String,
|
||||||
val code: String,
|
val code: String,
|
||||||
val cases: List<Case>
|
val cases: List<Case>
|
||||||
)
|
)
|
||||||
|
|
||||||
class CaseBuilder {
|
private class CaseBuilder {
|
||||||
val cases = arrayListOf<Case>()
|
val cases = arrayListOf<Case>()
|
||||||
|
|
||||||
fun case(name: String, testDeclaration: String, testDeclarationInit: String, testBlock: String,
|
fun case(name: String, testDeclaration: String, testDeclarationInit: String, testBlock: String,
|
||||||
@@ -247,7 +247,7 @@ class CaseBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestDataBuilder() {
|
private class TestDataBuilder {
|
||||||
val suites = arrayListOf<Suite>()
|
val suites = arrayListOf<Suite>()
|
||||||
|
|
||||||
fun suite(name: String, code: String, f: CaseBuilder.() -> Unit) {
|
fun suite(name: String, code: String, f: CaseBuilder.() -> Unit) {
|
||||||
@@ -279,7 +279,7 @@ class TestDataBuilder() {
|
|||||||
error("Unable to find or create test data directory: '$testDataDirPath'.")
|
error("Unable to find or create test data directory: '$testDataDirPath'.")
|
||||||
}
|
}
|
||||||
else if (isCreatingFromScratch) {
|
else if (isCreatingFromScratch) {
|
||||||
if (testDataDir.listFiles()?.all { it.delete() } ?: true) {
|
if (testDataDir.listFiles()?.all { it.delete() } != false) {
|
||||||
println("Create testdata files from scratch.")
|
println("Create testdata files from scratch.")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -337,53 +337,53 @@ class TestDataBuilder() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generate(testDataDirPath: String, f: TestDataBuilder.() -> Unit) {
|
private fun generate(testDataDirPath: String, f: TestDataBuilder.() -> Unit) {
|
||||||
val builder = TestDataBuilder()
|
val builder = TestDataBuilder()
|
||||||
builder.f()
|
builder.f()
|
||||||
builder.generate(testDataDirPath)
|
builder.generate(testDataDirPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
val DEFINITION_MARKER = "DEFINITION"
|
private val DEFINITION_MARKER = "DEFINITION"
|
||||||
val DECLARATION_MARKER = "DECLARATION"
|
private val DECLARATION_MARKER = "DECLARATION"
|
||||||
val DECLARATION_INIT_MARKER = "DECLARATION_INIT"
|
private val DECLARATION_INIT_MARKER = "DECLARATION_INIT"
|
||||||
val TEST_BLOCK_MARKER = "TEST_BLOCK"
|
private val TEST_BLOCK_MARKER = "TEST_BLOCK"
|
||||||
val KEYWORD_MARKER = "KEYWORD"
|
private val KEYWORD_MARKER = "KEYWORD"
|
||||||
|
|
||||||
val PREAMBLE_MESSAGE = "NOTE THIS FILE IS AUTO-GENERATED by the generateTestDataForReservedWords.kt. DO NOT EDIT!"
|
private val PREAMBLE_MESSAGE = "NOTE THIS FILE IS AUTO-GENERATED by the generateTestDataForReservedWords.kt. DO NOT EDIT!"
|
||||||
val PREAMBLE = """package foo
|
private val PREAMBLE = """package foo
|
||||||
|
|
||||||
// $PREAMBLE_MESSAGE
|
// $PREAMBLE_MESSAGE
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fun testRenamed(reference: String = "$KEYWORD_MARKER") = "testRenamed(\"$KEYWORD_MARKER\", { $reference })"
|
private fun testRenamed(reference: String = KEYWORD_MARKER) = "testRenamed(\"$KEYWORD_MARKER\", { $reference })"
|
||||||
fun testNotRenamed(reference: String = "$KEYWORD_MARKER") = "testNotRenamed(\"$KEYWORD_MARKER\", { $reference })"
|
private fun testNotRenamed(reference: String = KEYWORD_MARKER) = "testNotRenamed(\"$KEYWORD_MARKER\", { $reference })"
|
||||||
|
|
||||||
val testRenamedByName = testRenamed()
|
private val testRenamedByName = testRenamed()
|
||||||
val testRenamedByRef = testRenamed("$KEYWORD_MARKER()")
|
private val testRenamedByRef = testRenamed("$KEYWORD_MARKER()")
|
||||||
|
|
||||||
val testNotRenamedByName = testNotRenamed()
|
private val testNotRenamedByName = testNotRenamed()
|
||||||
val testNotRenamedByRef = testNotRenamed("$KEYWORD_MARKER()")
|
private val testNotRenamedByRef = testNotRenamed("$KEYWORD_MARKER()")
|
||||||
|
|
||||||
// KEYWORDS
|
// KEYWORDS
|
||||||
|
|
||||||
val SHOULD_BE_ESCAPED = JsDeclarationScope.RESERVED_WORDS.filter { it in KeywordStringsGenerated.KEYWORDS }.sorted()
|
private val SHOULD_BE_ESCAPED = JsDeclarationScope.RESERVED_WORDS.filter { it in KeywordStringsGenerated.KEYWORDS }.sorted()
|
||||||
val SHOULD_NOT_BE_ESCAPED = JsDeclarationScope.RESERVED_WORDS.filter { it !in SHOULD_BE_ESCAPED }.sorted()
|
private val SHOULD_NOT_BE_ESCAPED = JsDeclarationScope.RESERVED_WORDS.filter { it !in SHOULD_BE_ESCAPED }.sorted()
|
||||||
|
|
||||||
// all keywords by portions
|
// all keywords by portions
|
||||||
|
|
||||||
// cyclic keyword streams
|
// cyclic keyword streams
|
||||||
val s1 = SHOULD_BE_ESCAPED.cyclicSequence()
|
private val s1 = SHOULD_BE_ESCAPED.cyclicSequence()
|
||||||
val s2 = SHOULD_NOT_BE_ESCAPED.cyclicSequence()
|
private val s2 = SHOULD_NOT_BE_ESCAPED.cyclicSequence()
|
||||||
|
|
||||||
val PORTION_PART_SIZE = 2
|
private val PORTION_PART_SIZE = 2
|
||||||
|
|
||||||
fun nextKeywordPortion() = s1.take(PORTION_PART_SIZE).toList() + s2.take(PORTION_PART_SIZE).toList()
|
private fun nextKeywordPortion() = s1.take(PORTION_PART_SIZE).toList() + s2.take(PORTION_PART_SIZE).toList()
|
||||||
|
|
||||||
// CyclicStream
|
// CyclicStream
|
||||||
|
|
||||||
fun <T> List<T>.cyclicSequence() = CyclicSequence(this)
|
private fun <T> List<T>.cyclicSequence() = CyclicSequence(this)
|
||||||
|
|
||||||
class CyclicSequence<T>(val c: List<T>) : Sequence<T> {
|
private class CyclicSequence<T>(val c: List<T>) : Sequence<T> {
|
||||||
var i = 0
|
var i = 0
|
||||||
|
|
||||||
val iterator = object : Iterator<T> {
|
val iterator = object : Iterator<T> {
|
||||||
Reference in New Issue
Block a user