Implement artifacts test
^KTI-1103
This commit is contained in:
committed by
Space Team
parent
d1e5b252c9
commit
9160636a71
@@ -6909,12 +6909,6 @@
|
||||
<sha256 value="76d174792540e2775af94d03d10fb2d3c776e2cd0ac0ebf427d3e570072bb9ce" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.codehaus.plexus" name="plexus-utils" version="3.3.1">
|
||||
<artifact name="plexus-utils-3.3.1.jar">
|
||||
<md5 value="89d7dce81b0f90f469c7eec197ce299c" origin="Generated by Gradle"/>
|
||||
<sha256 value="4b570fcdbe5a894f249d2eb9b929358a9c88c3e548d227a80010461930222f2a" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.codehaus.plexus" name="plexus-utils" version="3.4.1">
|
||||
<artifact name="plexus-utils-3.4.1.jar">
|
||||
<md5 value="c155c4135ef7ba134659bf1af31c5156" origin="Generated by Gradle"/>
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
import java.nio.file.Paths
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testApi(kotlinStdlib("jdk8"))
|
||||
testImplementation(kotlinStdlib("jdk8"))
|
||||
testImplementation(project(":kotlin-test:kotlin-test-junit5"))
|
||||
testApiJUnit5()
|
||||
testImplementation("org.apache.maven:maven-model:3.8.7")
|
||||
testImplementation(projectTests(":compiler:tests-common-new"))
|
||||
}
|
||||
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform { }
|
||||
doFirst {
|
||||
val defaultMavenLocal = Paths.get(System.getProperty("user.home"), ".m2", "repository").toAbsolutePath()
|
||||
val mavenLocal = System.getProperty("maven.repo.local") ?: defaultMavenLocal
|
||||
systemProperty("maven.repo.local", mavenLocal)
|
||||
systemProperty("kotlin.version", version)
|
||||
}
|
||||
}
|
||||
|
||||
testsJar()
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.code
|
||||
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEqualsToFile
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.isTeamCityBuild
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
class ArtifactsTest {
|
||||
|
||||
private val kotlinVersion = System.getProperty("kotlin.version")
|
||||
private val mavenLocal = System.getProperty("maven.repo.local")
|
||||
private val localRepoPath = Paths.get(mavenLocal, "org/jetbrains/kotlin")
|
||||
private val expectedRepoPath = Paths.get("repo/artifacts-tests/src/test/resources/org/jetbrains/kotlin")
|
||||
|
||||
private val excludedProjects = setOf(
|
||||
"annotation-processor-example",
|
||||
"android-test-fixes",
|
||||
"org.jetbrains.kotlin.gradle-subplugin-example.gradle.plugin",
|
||||
"gradle-warnings-detector",
|
||||
"kotlin-compiler-args-properties",
|
||||
"kotlin-gradle-plugin-kpm-android",
|
||||
"kotlin-gradle-plugin-tcs-android",
|
||||
"kotlin-gradle-subplugin-example",
|
||||
"kotlin-java-example",
|
||||
"kotlin-maven-plugin-test",
|
||||
"org.jetbrains.kotlin.test.fixes.android.gradle.plugin",
|
||||
"org.jetbrains.kotlin.test.gradle-warnings-detector.gradle.plugin",
|
||||
"org.jetbrains.kotlin.test.kotlin-compiler-args-properties.gradle.plugin",
|
||||
)
|
||||
|
||||
@Test
|
||||
fun verifyArtifactFiles() {
|
||||
val visitedPoms = mutableSetOf<Path>()
|
||||
val actualPoms = Files.find(
|
||||
localRepoPath,
|
||||
Integer.MAX_VALUE,
|
||||
{ path: Path, fileAttributes: BasicFileAttributes ->
|
||||
fileAttributes.isRegularFile
|
||||
&& "${path.fileName}".endsWith(".pom", ignoreCase = true)
|
||||
&& path.contains(Paths.get(kotlinVersion))
|
||||
})
|
||||
actualPoms.forEach { actual ->
|
||||
val expectedPomPath = actual.toExpectedPath()
|
||||
if ("${expectedPomPath.parent.fileName}" !in excludedProjects) {
|
||||
val actualString = actual.toFile().readText().replace(kotlinVersion, "ArtifactsTest.version")
|
||||
assertEqualsToFile(expectedPomPath, actualString)
|
||||
visitedPoms.add(expectedPomPath)
|
||||
} else {
|
||||
if (isTeamCityBuild) fail("Excluded project in actual artifacts: $actual")
|
||||
}
|
||||
}
|
||||
|
||||
val expectedPoms = Files.find(
|
||||
expectedRepoPath,
|
||||
Integer.MAX_VALUE,
|
||||
{ path: Path, fileAttributes: BasicFileAttributes ->
|
||||
fileAttributes.isRegularFile
|
||||
&& "${path.fileName}".endsWith(".pom", ignoreCase = true)
|
||||
})
|
||||
expectedPoms.forEach {
|
||||
assertTrue(it in visitedPoms, "Missing actual pom for expected pom: $it")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* convert:
|
||||
* ${mavenLocal}/org/jetbrains/kotlin/artifact/version/artifact-version.pom
|
||||
* to:
|
||||
* ${expectedRepository}/org/jetbrains/kotlin/artifact/artifact.pom
|
||||
*/
|
||||
private fun Path.toExpectedPath(): Path {
|
||||
val artifactDirPath = localRepoPath.relativize(this).parent.parent
|
||||
val expectedFileName = "${artifactDirPath.fileName}.pom"
|
||||
return expectedRepoPath.resolve(artifactDirPath.resolve(expectedFileName))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user