[Tests] Drop DCE tests
^KT-44602
This commit is contained in:
committed by
Space Team
parent
e03af07a1c
commit
0ae7c66fc8
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.generators.util.TestGeneratorUtil
|
||||
import org.jetbrains.kotlin.incremental.*
|
||||
import org.jetbrains.kotlin.js.test.fir.*
|
||||
import org.jetbrains.kotlin.js.test.ir.*
|
||||
import org.jetbrains.kotlin.js.testOld.AbstractDceTest
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.js.test.fir.AbstractFirLightTreeJsIrTextTest
|
||||
import org.jetbrains.kotlin.js.test.ir.AbstractMultiModuleOrderTest
|
||||
@@ -29,12 +28,6 @@ fun main(args: Array<String>) {
|
||||
//generateTestDataForReservedWords()
|
||||
|
||||
generateTestGroupSuite(args) {
|
||||
testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") {
|
||||
testClass<AbstractDceTest> {
|
||||
model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("js/js.tests/tests-gen", "compiler/testData", testRunnerMethodName = "runTest0") {
|
||||
testClass<AbstractClassicJsKlibEvolutionTest> {
|
||||
model("klib/evolution", targetBackend = TargetBackend.JS_IR)
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.testOld
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.js.dce.DeadCodeElimination
|
||||
import org.jetbrains.kotlin.js.dce.InputFile
|
||||
import org.jetbrains.kotlin.js.dce.InputResource
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractDceTest : TestCase() {
|
||||
fun doTest(filePath: String) {
|
||||
val file = File(filePath)
|
||||
val fileContents = file.readText()
|
||||
val inputFile = InputFile(InputResource.file(filePath), null,
|
||||
File(pathToOutputDir, file.relativeTo(File(pathToTestDir)).path).path, "main")
|
||||
val dceResult = DeadCodeElimination.run(setOf(inputFile), extractDeclarations(REQUEST_REACHABLE_PATTERN, fileContents), true) { _, _ -> }
|
||||
val reachableNodeStrings = dceResult.reachableNodes.map { it.toString().removePrefix("<unknown>.") }.toSet()
|
||||
|
||||
for (assertedDeclaration in extractDeclarations(ASSERT_REACHABLE_PATTERN, fileContents)) {
|
||||
TestCase.assertTrue("Declaration $assertedDeclaration not reached", assertedDeclaration in reachableNodeStrings)
|
||||
}
|
||||
for (assertedDeclaration in extractDeclarations(ASSERT_UNREACHABLE_PATTERN, fileContents)) {
|
||||
TestCase.assertTrue("Declaration $assertedDeclaration reached", assertedDeclaration !in reachableNodeStrings)
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractDeclarations(regex: Regex, fileContents: String): Set<String> =
|
||||
regex.findAll(fileContents).map { it.groupValues[1] }.toSet()
|
||||
|
||||
companion object {
|
||||
private val ASSERT_REACHABLE_PATTERN = Regex("^ *// *ASSERT_REACHABLE: (.+) *$", RegexOption.MULTILINE)
|
||||
private val ASSERT_UNREACHABLE_PATTERN = Regex("^ *// *ASSERT_UNREACHABLE: (.+) *$", RegexOption.MULTILINE)
|
||||
private val REQUEST_REACHABLE_PATTERN = Regex("^ *// *REQUEST_REACHABLE: (.+) *$", RegexOption.MULTILINE)
|
||||
|
||||
private val pathToTestDir = "js/js.translator/testData/dce"
|
||||
private val pathToOutputDir = System.getProperty("kotlin.js.test.root.out.dir") ?: error("'kotlin.js.test.root.out.dir' is not set")
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.testOld;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("js/js.translator/testData/dce")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class DceTestGenerated extends AbstractDceTest {
|
||||
private void runTest(String testDataFilePath) {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDce() {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/dce"), Pattern.compile("(.+)\\.js"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("amd.js")
|
||||
public void testAmd() {
|
||||
runTest("js/js.translator/testData/dce/amd.js");
|
||||
}
|
||||
|
||||
@TestMetadata("arrayAccess.js")
|
||||
public void testArrayAccess() {
|
||||
runTest("js/js.translator/testData/dce/arrayAccess.js");
|
||||
}
|
||||
|
||||
@TestMetadata("commonjs.js")
|
||||
public void testCommonjs() {
|
||||
runTest("js/js.translator/testData/dce/commonjs.js");
|
||||
}
|
||||
|
||||
@TestMetadata("cycle.js")
|
||||
public void testCycle() {
|
||||
runTest("js/js.translator/testData/dce/cycle.js");
|
||||
}
|
||||
|
||||
@TestMetadata("localVarAndFunction.js")
|
||||
public void testLocalVarAndFunction() {
|
||||
runTest("js/js.translator/testData/dce/localVarAndFunction.js");
|
||||
}
|
||||
|
||||
@TestMetadata("typeOf.js")
|
||||
public void testTypeOf() {
|
||||
runTest("js/js.translator/testData/dce/typeOf.js");
|
||||
}
|
||||
}
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
define(['exports'], function (exports) {
|
||||
function foo() {
|
||||
}
|
||||
function bar() {
|
||||
}
|
||||
function ignore() {
|
||||
}
|
||||
|
||||
bar();
|
||||
|
||||
exports.foo = foo;
|
||||
exports.bar = bar;
|
||||
exports.ignore = ignore;
|
||||
});
|
||||
|
||||
// REQUEST_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: main.bar
|
||||
// ASSERT_UNREACHABLE: main.ignore
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
(function(_) {
|
||||
var x = {};
|
||||
function foo() {
|
||||
return x["bar"]();
|
||||
}
|
||||
x.bar = function() {
|
||||
return "bar";
|
||||
};
|
||||
x.baz = function() {
|
||||
return "baz";
|
||||
};
|
||||
_.foo = foo;
|
||||
})(module.exports);
|
||||
|
||||
// REQUEST_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: x.bar
|
||||
// ASSERT_UNREACHABLE: x.baz
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
function foo() {
|
||||
}
|
||||
function bar() {
|
||||
}
|
||||
function ignore() {
|
||||
}
|
||||
|
||||
bar();
|
||||
|
||||
module.exports.foo = foo;
|
||||
module.exports.bar = bar;
|
||||
module.exports.ignore = ignore;
|
||||
|
||||
// REQUEST_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: main.bar
|
||||
// ASSERT_REACHABLE: main.foo
|
||||
// ASSERT_UNREACHABLE: main.ignore
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
function A() {
|
||||
}
|
||||
A.prototype = Object.create(A);
|
||||
A.prototype.constructor = A;
|
||||
@@ -1,27 +0,0 @@
|
||||
(function(_, Kotlin) {
|
||||
Kotlin.defineInlineFunction("bar", Kotlin.wrapFunction(function() {
|
||||
function baz() {
|
||||
return "bar";
|
||||
}
|
||||
return function() {
|
||||
return baz();
|
||||
};
|
||||
}));
|
||||
return _;
|
||||
})(module.exports, require("kotlin"));
|
||||
|
||||
(function(_) {
|
||||
function baz() {
|
||||
return "baz";
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return baz();
|
||||
}
|
||||
_.foo = foo;
|
||||
})(module.exports);
|
||||
|
||||
|
||||
// REQUEST_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: baz
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
(function(_) {
|
||||
var x = {};
|
||||
x.y = {};
|
||||
x.y.bar = function() {
|
||||
return "bar";
|
||||
};
|
||||
function foo() {
|
||||
return typeof x.y;
|
||||
}
|
||||
_.foo = foo;
|
||||
})(module.exports);
|
||||
|
||||
// REQUEST_REACHABLE: main.foo
|
||||
// ASSERT_REACHABLE: x.y
|
||||
// ASSERT_UNREACHABLE: x.y.bar
|
||||
Reference in New Issue
Block a user