From 37861a36ba96ae3b60d095a814ea5d11ccbfa17d Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Mon, 6 Jun 2022 12:25:21 +0300 Subject: [PATCH] Remove NPM validation We will drop complete support of NPM as soon as JS IR is declared stable and this test is already a deadweight as it was never run due to misconfiguration --- integration-testing/build.gradle | 23 +----- .../npmTest/kotlin/NpmPublicationValidator.kt | 71 ------------------- 2 files changed, 1 insertion(+), 93 deletions(-) delete mode 100644 integration-testing/src/npmTest/kotlin/NpmPublicationValidator.kt diff --git a/integration-testing/build.gradle b/integration-testing/build.gradle index 4e025c58dc..97c9201b69 100644 --- a/integration-testing/build.gradle +++ b/integration-testing/build.gradle @@ -14,11 +14,6 @@ repositories { } sourceSets { - npmTest { - kotlin - compileClasspath += sourceSets.test.runtimeClasspath - runtimeClasspath += sourceSets.test.runtimeClasspath - } mavenTest { kotlin compileClasspath += sourceSets.test.runtimeClasspath @@ -43,20 +38,6 @@ compileDebugAgentTestKotlin { } } -task npmTest(type: Test) { - def sourceSet = sourceSets.npmTest - environment "projectRoot", project.rootDir - environment "deployVersion", version - def dryRunNpm = project.properties['dryRun'] - def doRun = dryRunNpm == "true" // so that we don't accidentally publish anything, especially before the test - onlyIf { doRun } - if (doRun) { // `onlyIf` only affects execution of the task, not the dependency subtree - dependsOn(project(':').getTasksByName("publishNpm", true)) - } - testClassesDirs = sourceSet.output.classesDirs - classpath = sourceSet.runtimeClasspath -} - task mavenTest(type: Test) { environment "version", version def sourceSet = sourceSets.mavenTest @@ -96,8 +77,6 @@ task coreAgentTest(type: Test) { dependencies { testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" testImplementation 'junit:junit:4.12' - npmTestImplementation 'org.apache.commons:commons-compress:1.18' - npmTestImplementation 'com.google.code.gson:gson:2.8.5' debugAgentTestImplementation project(':kotlinx-coroutines-core') debugAgentTestImplementation project(':kotlinx-coroutines-debug') coreAgentTestImplementation project(':kotlinx-coroutines-core') @@ -108,5 +87,5 @@ compileTestKotlin { } check { - dependsOn([npmTest, mavenTest, debugAgentTest, coreAgentTest]) + dependsOn([mavenTest, debugAgentTest, coreAgentTest]) } diff --git a/integration-testing/src/npmTest/kotlin/NpmPublicationValidator.kt b/integration-testing/src/npmTest/kotlin/NpmPublicationValidator.kt deleted file mode 100644 index 8e1b9f99bf..0000000000 --- a/integration-testing/src/npmTest/kotlin/NpmPublicationValidator.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package kotlinx.coroutines.validator - -import com.google.gson.* -import org.apache.commons.compress.archivers.tar.* -import org.junit.* -import java.io.* -import java.util.zip.* -import org.junit.Assert.* - -class NpmPublicationValidator { - private val VERSION = System.getenv("deployVersion")!! - private val BUILD_DIR = System.getenv("projectRoot")!! - private val NPM_ARTIFACT = "$BUILD_DIR/kotlinx-coroutines-core/build/npm/kotlinx-coroutines-core-$VERSION.tgz" - - @Test - fun testPackageJson() { - println("Checking dependencies of $NPM_ARTIFACT") - val visited = visit("package.json") { - val json = JsonParser().parse(content()).asJsonObject - assertEquals(VERSION, json["version"].asString) - assertNull(json["dependencies"]) - val peerDependencies = json["peerDependencies"].asJsonObject - assertEquals(1, peerDependencies.size()) - assertNotNull(peerDependencies["kotlin"]) - } - assertEquals(1, visited) - } - - @Test - fun testAtomicfuDependencies() { - println("Checking contents of $NPM_ARTIFACT") - val visited = visit(".js") { - val content = content() - assertFalse(content, content.contains("atomicfu", true)) - assertFalse(content, content.contains("atomicint", true)) - assertFalse(content, content.contains("atomicboolean", true)) - } - assertEquals(2, visited) - } - - private fun InputStream.content(): String { - val bais = ByteArrayOutputStream() - val buffer = ByteArray(DEFAULT_BUFFER_SIZE) - var read = read(buffer, 0, DEFAULT_BUFFER_SIZE) - while (read >= 0) { - bais.write(buffer, 0, read) - read = read(buffer, 0, DEFAULT_BUFFER_SIZE) - } - return bais.toString() - } - - private inline fun visit(fileSuffix: String, block: InputStream.(entry: TarArchiveEntry) -> Unit): Int { - var visited = 0 - TarArchiveInputStream(GZIPInputStream(FileInputStream(NPM_ARTIFACT))).use { tais -> - var entry: TarArchiveEntry? = tais.nextTarEntry ?: return 0 - do { - if (entry!!.name.endsWith(fileSuffix)) { - ++visited - tais.block(entry) - } - entry = tais.nextTarEntry - } while (entry != null) - - return visited - } - } -}