Test links reference existing files
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ the Kotlin IntelliJ IDEA plugin:
|
||||
- Origin: Derived from boost special math functions, Copyright Eric Ford & Hubert Holin 2001.
|
||||
|
||||
- Path: libraries/stdlib/wasm/internal/kotlin/wasm/internal/Number2String.kt
|
||||
- License: Apache 2 ([third_party/assemblyscript_license.txt][assemblyscript])
|
||||
- License: Apache 2 ([license/third_party/assemblyscript_license.txt][assemblyscript])
|
||||
- Origin: Derived from assemblyscript standard library
|
||||
|
||||
- Path: plugins/lint/android-annotations
|
||||
|
||||
@@ -5,23 +5,25 @@
|
||||
|
||||
package org.jetbrains.kotlin.code
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.assertEmpty
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class LicensesTests {
|
||||
companion object {
|
||||
private const val licenseReadmePath = "license/README.md"
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLinksDefinitions() {
|
||||
val licenseDir = File("license")
|
||||
|
||||
val linkDefinitionRegExp = Regex(pattern = "\\[(\\w+)]:.+")
|
||||
val linkRegExp = Regex(pattern = "]\\s?\\[(\\w+)]")
|
||||
|
||||
val linksUsages = mutableSetOf<String>()
|
||||
val linksDefinitions = mutableSetOf<String>()
|
||||
|
||||
val readmeFile = File(licenseDir, "README.md")
|
||||
val readmeFile = File(licenseReadmePath)
|
||||
readmeFile.useLines { lineSequence ->
|
||||
lineSequence.forEach { line ->
|
||||
val definitionMatch = linkDefinitionRegExp.matchEntire(line)
|
||||
@@ -39,4 +41,18 @@ class LicensesTests {
|
||||
linksDefinitions.sorted()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLicensesAreExistingFiles() {
|
||||
val licenseReferenceRegexp = Regex("\\[([^]]*third_party/[^]]*\\.txt)]")
|
||||
val readmeFile = File(licenseReadmePath)
|
||||
val linkedInReadme = readmeFile.useLines { lineSequence ->
|
||||
lineSequence.flatMap { line ->
|
||||
licenseReferenceRegexp.findAll(line).map { it.groups[1]?.value ?: error("Should be present because of match") }
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
val missingFiles = linkedInReadme.filterNot { path -> File(path).exists() }
|
||||
assertEmpty("Files for licenses are missing", missingFiles)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user