Minor, remove obsolete abstract test classes
This commit is contained in:
+1
-9
@@ -12,7 +12,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure;
|
import org.jetbrains.kotlin.ObsoleteTestInfrastructure;
|
||||||
import org.jetbrains.kotlin.TestsRuntimeError;
|
import org.jetbrains.kotlin.TestsRuntimeError;
|
||||||
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
||||||
import org.jetbrains.kotlin.codegen.ir.AbstractFirBlackBoxCodegenTest;
|
|
||||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
|
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
|
||||||
import org.jetbrains.kotlin.psi.KtFile;
|
import org.jetbrains.kotlin.psi.KtFile;
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
||||||
@@ -120,13 +119,6 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isIgnoredTarget(@NotNull File wholeFile) {
|
protected boolean isIgnoredTarget(@NotNull File wholeFile) {
|
||||||
try {
|
return InTextDirectivesUtils.isIgnoredTarget(getBackend(), wholeFile);
|
||||||
return InTextDirectivesUtils.isIgnoredTarget(getBackend(), wholeFile) ||
|
|
||||||
(this instanceof AbstractFirBlackBoxCodegenTest &&
|
|
||||||
InTextDirectivesUtils.isDirectiveDefined(FileUtil.loadFile(wholeFile), "IGNORE_BACKEND_FIR: JVM_IR"));
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
throw ExceptionUtilsKt.rethrow(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 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.codegen
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
@OptIn(ObsoleteTestInfrastructure::class)
|
|
||||||
abstract class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest() {
|
|
||||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
|
||||||
super.doMultiFileTest(wholeFile, files)
|
|
||||||
try {
|
|
||||||
InlineTestUtil.checkNoCallsToInline(
|
|
||||||
initializedClassLoader.allGeneratedFiles.filterClassFiles(),
|
|
||||||
skipParameterCheckingInDirectives = files.any { "NO_CHECK_LAMBDA_INLINING" in it.directives },
|
|
||||||
skippedMethods = files.flatMapTo(mutableSetOf()) { it.directives.listValues("SKIP_INLINE_CHECK_IN") ?: emptyList() }
|
|
||||||
)
|
|
||||||
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles(), false)
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
println(generateToText())
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-180
@@ -1,180 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 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.codegen;
|
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable;
|
|
||||||
import com.intellij.openapi.util.Disposer;
|
|
||||||
import kotlin.Pair;
|
|
||||||
import kotlin.text.StringsKt;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.kotlin.cli.common.modules.ModuleBuilder;
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys;
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration;
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager;
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile;
|
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
|
||||||
import org.jetbrains.kotlin.test.TargetBackend;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTestCase {
|
|
||||||
private File tmpdir;
|
|
||||||
protected File aDir;
|
|
||||||
protected File bDir;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
tmpdir = KotlinTestUtils.tmpDirForTest(this);
|
|
||||||
aDir = new File(tmpdir, "a");
|
|
||||||
bDir = new File(tmpdir, "b");
|
|
||||||
KtTestUtil.mkdirs(aDir);
|
|
||||||
KtTestUtil.mkdirs(bDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<? extends TestFile> files) {
|
|
||||||
boolean isIgnored = InTextDirectivesUtils.isIgnoredTarget(getBackend(), wholeFile);
|
|
||||||
doTwoFileTest((List<TestFile>) files, !isIgnored);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected Pair<ClassFileFactory, ClassFileFactory> doTwoFileTest(@NotNull List<TestFile> files, boolean reportProblems) {
|
|
||||||
// Note that it may be beneficial to improve this test to handle many files, compiling them successively against all previous
|
|
||||||
assert files.size() == 2 || (files.size() == 3 && files.get(2).name.equals("CoroutineUtil.kt")) : "There should be exactly two files in this test";
|
|
||||||
TestFile fileA = files.get(0);
|
|
||||||
TestFile fileB = files.get(1);
|
|
||||||
ClassFileFactory factoryA = compileA(fileA, files);
|
|
||||||
ClassFileFactory factoryB = null;
|
|
||||||
try {
|
|
||||||
factoryB = compileB(fileB, files);
|
|
||||||
invokeBox(PackagePartClassUtils.getFilePartShortName(new File(fileB.name).getName()));
|
|
||||||
}
|
|
||||||
catch (Throwable e) {
|
|
||||||
if (reportProblems) {
|
|
||||||
String result = "FIRST: \n\n" + factoryA.createText();
|
|
||||||
if (factoryB != null) {
|
|
||||||
result += "\n\nSECOND: \n\n" + factoryB.createText();
|
|
||||||
}
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
throw ExceptionUtilsKt.rethrow(e);
|
|
||||||
}
|
|
||||||
return new Pair<>(factoryA, factoryB);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void invokeBox(@NotNull String className) throws Exception {
|
|
||||||
callBoxMethodAndCheckResult(createGeneratedClassLoader(), className);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean parseDirectivesPerFiles() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private URLClassLoader createGeneratedClassLoader() throws Exception {
|
|
||||||
return new URLClassLoader(
|
|
||||||
new URL[]{bDir.toURI().toURL(), aDir.toURI().toURL()},
|
|
||||||
ForTestCompileRuntime.runtimeAndReflectJarClassLoader()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected TargetBackend getBackendA() {
|
|
||||||
return getBackend();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected TargetBackend getBackendB() {
|
|
||||||
return getBackend();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ClassFileFactory compileA(@NotNull TestFile testFile, List<TestFile> files) {
|
|
||||||
Disposable compileDisposable = createDisposable("compileA");
|
|
||||||
CompilerConfiguration configuration = createConfiguration(
|
|
||||||
ConfigurationKind.ALL, getTestJdkKind(files), getBackendA(),
|
|
||||||
Collections.singletonList(KtTestUtil.getAnnotationsJar()),
|
|
||||||
Collections.emptyList(), Collections.singletonList(testFile)
|
|
||||||
);
|
|
||||||
|
|
||||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, "a");
|
|
||||||
|
|
||||||
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
|
|
||||||
compileDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
|
||||||
|
|
||||||
List<TestFile> filesToCompile =
|
|
||||||
files.size() == 2
|
|
||||||
? Collections.singletonList(testFile)
|
|
||||||
// A-file and CoroutineUtil.kt
|
|
||||||
: Arrays.asList(testFile, files.get(2));
|
|
||||||
|
|
||||||
return compileKotlin(filesToCompile, aDir, environment, compileDisposable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ClassFileFactory compileB(@NotNull TestFile testFile, List<TestFile> files) {
|
|
||||||
String commonHeader = StringsKt.substringBefore(files.get(0).content, "FILE:", "");
|
|
||||||
CompilerConfiguration configuration = createConfiguration(
|
|
||||||
ConfigurationKind.ALL, getTestJdkKind(files), getBackendB(),
|
|
||||||
Arrays.asList(KtTestUtil.getAnnotationsJar(), aDir),
|
|
||||||
Collections.emptyList(), Arrays.asList(testFile, new TestFile("header", commonHeader))
|
|
||||||
);
|
|
||||||
|
|
||||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, "b");
|
|
||||||
|
|
||||||
Disposable compileDisposable = createDisposable("compileB");
|
|
||||||
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(
|
|
||||||
compileDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES
|
|
||||||
);
|
|
||||||
|
|
||||||
return compileKotlin(Collections.singletonList(testFile), bDir, environment, compileDisposable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Disposable createDisposable(String debugName) {
|
|
||||||
Disposable disposable = Disposer.newDisposable("CompileDisposable" + debugName);
|
|
||||||
Disposer.register(getTestRootDisposable(), disposable);
|
|
||||||
return disposable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ClassFileFactory compileKotlin(
|
|
||||||
@NotNull List<TestFile> files,
|
|
||||||
@NotNull File outputDir,
|
|
||||||
@NotNull KotlinCoreEnvironment environment,
|
|
||||||
@NotNull Disposable disposable
|
|
||||||
) {
|
|
||||||
|
|
||||||
List<KtFile> ktFiles =
|
|
||||||
files.stream().map(file -> KtTestUtil.createFile(file.name, file.content, environment.getProject()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
ModuleVisibilityManager.SERVICE.getInstance(environment.getProject()).addModule(
|
|
||||||
new ModuleBuilder("module for test", tmpdir.getAbsolutePath(), "test")
|
|
||||||
);
|
|
||||||
|
|
||||||
ClassFileFactory outputFiles = GenerationUtils.compileFilesTo(ktFiles, environment, outputDir);
|
|
||||||
|
|
||||||
Disposer.dispose(disposable);
|
|
||||||
return outputFiles;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.codegen.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
|
||||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
|
||||||
|
|
||||||
@OptIn(ObsoleteTestInfrastructure::class)
|
|
||||||
abstract class AbstractFirBlackBoxCodegenTest : AbstractIrBlackBoxCodegenTest() {
|
|
||||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
|
||||||
super.updateConfiguration(configuration)
|
|
||||||
configuration.put(CommonConfigurationKeys.USE_FIR, true)
|
|
||||||
configuration.put(JVMConfigurationKeys.IR, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2020 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.codegen.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
|
||||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
|
||||||
|
|
||||||
abstract class AbstractFirBlackBoxInlineCodegenTest : AbstractIrBlackBoxInlineCodegenTest() {
|
|
||||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
|
||||||
super.updateConfiguration(configuration)
|
|
||||||
configuration.put(CommonConfigurationKeys.USE_FIR, true)
|
|
||||||
configuration.put(JVMConfigurationKeys.IR, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 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.codegen.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
|
|
||||||
import org.jetbrains.kotlin.codegen.AbstractBlackBoxCodegenTest
|
|
||||||
import org.jetbrains.kotlin.test.TargetBackend
|
|
||||||
|
|
||||||
@ObsoleteTestInfrastructure("org.jetbrains.kotlin.test.runners.codegen.AbstractIrBlackBoxCodegenTest")
|
|
||||||
abstract class AbstractIrBlackBoxCodegenTest : AbstractBlackBoxCodegenTest() {
|
|
||||||
override val backend = TargetBackend.JVM_IR
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.codegen.ir
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
|
|
||||||
import org.jetbrains.kotlin.codegen.AbstractBlackBoxInlineCodegenTest
|
|
||||||
import org.jetbrains.kotlin.test.TargetBackend
|
|
||||||
|
|
||||||
@OptIn(ObsoleteTestInfrastructure::class)
|
|
||||||
abstract class AbstractIrBlackBoxInlineCodegenTest : AbstractBlackBoxInlineCodegenTest() {
|
|
||||||
override val backend = TargetBackend.JVM_IR
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user