From 77399a175ed1e7acba598ba25be6aed822aae13c Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 28 Aug 2019 14:52:13 +0200 Subject: [PATCH] Cleanup compiler warnings in compiler tests --- .../tests/org/jetbrains/kotlin/cli/CustomCliTest.kt | 2 +- .../org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt | 7 +++---- .../experimental/integration/CompilerApiTest.kt | 2 +- .../experimental/integration/CompilerDaemonTest.kt | 7 ++++--- .../experimental/unit/ClientSerializationTest.kt | 6 +++--- .../daemon/experimental/unit/ConnectionsTest.kt | 5 +++-- .../jetbrains/kotlin/scripts/ScriptTemplateTest.kt | 2 +- .../org/jetbrains/kotlin/util/KotlinVersionsTest.kt | 11 +++++------ 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt index 74771ebad91..202af8b98fb 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/CustomCliTest.kt @@ -5,10 +5,10 @@ package org.jetbrains.kotlin.cli -import junit.framework.Assert import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.test.CompilerTestUtil import org.jetbrains.kotlin.test.TestCaseWithTmpdir +import org.junit.Assert import java.io.File import java.util.jar.JarFile diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt index b96f412b955..07e999bc58a 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/CompilerDaemonTest.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.daemon import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtilRt -import junit.framework.Assert import junit.framework.TestCase import org.jetbrains.kotlin.cli.AbstractCliTest import org.jetbrains.kotlin.cli.common.messages.MessageRenderer @@ -50,7 +49,6 @@ import kotlin.script.experimental.dependencies.asSuccess import kotlin.script.templates.ScriptTemplateDefinition import kotlin.test.fail - val TIMEOUT_DAEMON_RUNNER_EXIT_MS = 10000L class CompilerDaemonTest : KotlinIntegrationTestBase() { @@ -204,12 +202,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() { for (assertArgValue in allAssetionsArgs) { withDaemonJvmOptionsSetTo(assertArgValue) { - Assert.assertEquals(assertArgValue, assertionsJvmArgs()) + assertEquals(assertArgValue, assertionsJvmArgs()) } } withDaemonJvmOptionsSetTo(null) { - Assert.assertEquals("-ea", assertionsJvmArgs()) + assertEquals("-ea", assertionsJvmArgs()) } } @@ -757,6 +755,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() { } }, port = SOCKET_ANY_FREE_PORT) val strm = ByteArrayOutputStream() + @Suppress("DEPRECATION") val code = daemon!!.remoteCompile(CompileService.NO_SESSION, CompileService.TargetPlatform.JVM, arrayOf("-include-runtime", file.absolutePath, "-d", jar), diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt index 8ec425be8b0..8c5b6c505ab 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerApiTest.kt @@ -186,7 +186,7 @@ class CompilerApiTest : KotlinIntegrationTestBase() { run(getHelloAppBaseDir(), "hello.run", "-cp", jar, "Hello.HelloKt") } - private fun terminate(daemonOptions: DaemonOptions) { + private fun terminate(@Suppress("UNUSED_PARAMETER") daemonOptions: DaemonOptions) { println("\n\nkillall -9 Console && open ${logFiles.joinToString(" ")}\n\n") log.info("in finally") // runBlocking { diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt index ce6d0502f25..afe961e587a 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/integration/CompilerDaemonTest.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.daemon.experimental.integration -import junit.framework.Assert import junit.framework.TestCase import kotlinx.coroutines.* import org.jetbrains.kotlin.cli.AbstractCliTest @@ -281,12 +280,12 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() { for (assertArgValue in allAssetionsArgs) { withDaemonJvmOptionsSetTo(assertArgValue) { - Assert.assertEquals(assertArgValue, assertionsJvmArgs()) + assertEquals(assertArgValue, assertionsJvmArgs()) } } withDaemonJvmOptionsSetTo(null) { - Assert.assertEquals("-ea", assertionsJvmArgs()) + assertEquals("-ea", assertionsJvmArgs()) } } @@ -778,6 +777,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() { private val PARALLEL_THREADS_TO_COMPILE = 10 private val PARALLEL_WAIT_TIMEOUT_S = 60L + @UseExperimental(ObsoleteCoroutinesApi::class) private fun runCompile( daemon: CompileServiceAsync, resultCodes: Array, @@ -877,6 +877,7 @@ class CompilerDaemonTest : KotlinIntegrationTestBase() { const val connectionFailedErr = -100 } + @UseExperimental(ObsoleteCoroutinesApi::class) fun ignore_testParallelDaemonStart() { val doneLatch = CountDownLatch(ParallelStartParams.threads) diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ClientSerializationTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ClientSerializationTest.kt index d2ce1a087f7..0be9a6e7f45 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ClientSerializationTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ClientSerializationTest.kt @@ -31,7 +31,7 @@ class TestServer(val serverPort: Int = 6999) { log.info("accepting clientSocket...") val client = serverSocket.accept() log.info("client accepted! (${client.remoteAddress})") - val (input, output) = client.openIO(log) + client.openIO(log) true } @@ -77,7 +77,7 @@ class ClientSerializationTest : KotlinIntegrationTestBase() { fun ignore_testDefaultClient() = abstractSerializationTest( { DefaultClient(testServer.serverPort) }, { client, client2 -> assert(client.serverPort == client2.serverPort) }, - { client, client2 -> + { _, client2 -> client2.log.info("abacaba (2)") log.info("test passed") } @@ -90,4 +90,4 @@ class ClientSerializationTest : KotlinIntegrationTestBase() { fun ignore_testRMIWrapper() = abstractSerializationTest({ CompilerServicesFacadeBaseClientSideImpl(testServer.serverPort).toRMI() }) -} \ No newline at end of file +} diff --git a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ConnectionsTest.kt b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ConnectionsTest.kt index 91b564cdd15..41dab66e541 100644 --- a/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ConnectionsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/daemon/experimental/unit/ConnectionsTest.kt @@ -241,7 +241,7 @@ class ConnectionsTest : KotlinIntegrationTestBase() { { daemons -> daemons[0].daemon }, { d -> d.getDaemonInfo() }, { d -> d.registerClient(generateClient()) }, - { d -> -1 }, + { _ -> -1 }, 1.takeIf { shouldCheckNumber }, extraAction ) @@ -351,6 +351,7 @@ class ConnectionsTest : KotlinIntegrationTestBase() { val servicesClient = services.clientSide val compResultsClient = kotlinCompilerClient.createCompResults().clientSide val threadCount = 10 + @UseExperimental(ObsoleteCoroutinesApi::class) fun runThread(i: Int) = async(newSingleThreadContext("thread_$i")) { val jar = tmpdir.absolutePath + File.separator + "hello.$i.jar" @@ -386,4 +387,4 @@ class ConnectionsTest : KotlinIntegrationTestBase() { } } -} \ No newline at end of file +} diff --git a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt index 288da5fa5f0..44c045228f1 100644 --- a/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/scripts/ScriptTemplateTest.kt @@ -557,7 +557,7 @@ abstract class ScriptWithBaseClass(val num: Int, passthrough: Int) : TestDSLClas @ScriptTemplateDefinition( scriptFilePattern =".*\\.kts", resolver = TestKotlinScriptDependenciesResolver::class) -abstract class ScriptWithoutParams(num: Int) +abstract class ScriptWithoutParams(@Suppress("UNUSED_PARAMETER") num: Int) @ScriptTemplateDefinition( scriptFilePattern =".*\\.kts", diff --git a/compiler/tests/org/jetbrains/kotlin/util/KotlinVersionsTest.kt b/compiler/tests/org/jetbrains/kotlin/util/KotlinVersionsTest.kt index 9891b7fd72a..9d13cb01b04 100644 --- a/compiler/tests/org/jetbrains/kotlin/util/KotlinVersionsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/util/KotlinVersionsTest.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.util import com.intellij.openapi.util.io.FileUtil -import com.intellij.util.Processor import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.config.KotlinCompilerVersion import org.jetbrains.kotlin.config.LanguageVersion @@ -27,7 +26,6 @@ import org.junit.Assert import org.xml.sax.Attributes import org.xml.sax.helpers.DefaultHandler import java.io.File -import java.util.* import javax.xml.parsers.SAXParserFactory class KotlinVersionsTest : KtUsefulTestCase() { @@ -89,16 +87,17 @@ class KotlinVersionsTest : KtUsefulTestCase() { val poms = arrayListOf() - FileUtil.processFilesRecursively(File("libraries"), Processor { file -> - if (file.name == "pom.xml") { + FileUtil.processFilesRecursively(File("libraries")) { file -> + if (file.name == "pom.xml" && file.toPath().none { it.fileName.toString() == "target" }) { + println(file.path) if (loadValueFromPomXml(file.path, listOf("project", "parent", "artifactId")) == "kotlin-project") { val version = loadValueFromPomXml(file.path, listOf("project", "parent", "version")) - ?: error("No version found in pom.xml at $file") + ?: error("No version found in pom.xml at $file") poms.add(Pom(file.path, version)) } } true - }, Processor { file -> file.name != "target" }) + } Assert.assertTrue( "Too few (<= 10) pom.xml files found. Something must be wrong in the test or in the project structure",