[build][test] enable external compiler tests
This commit is contained in:
@@ -52,24 +52,6 @@ configurations {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
|
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
|
||||||
cli_bc project(path: ':kotlin-native:backend.native', configuration: 'cli_bc')
|
cli_bc project(path: ':kotlin-native:backend.native', configuration: 'cli_bc')
|
||||||
def updateTestData = true
|
|
||||||
if (project.hasProperty("kotlinProjectPath")) {
|
|
||||||
def kotlinProj = project.property("kotlinProjectPath").toString()
|
|
||||||
def testDataZip = Paths.get(kotlinProj, "dist", "kotlin-test-data.zip").toFile()
|
|
||||||
if (testDataZip.exists()) {
|
|
||||||
update_tests files(testDataZip)
|
|
||||||
updateTestData = false
|
|
||||||
} else {
|
|
||||||
println("WARN: using tests provided by gradle.properties. Please execute :kotlin:zipTestData")
|
|
||||||
}
|
|
||||||
def stdlibTestsZip = Paths.get(kotlinProj, "dist", "kotlin-stdlib-tests.zip").toFile()
|
|
||||||
if (stdlibTestsZip.exists()) {
|
|
||||||
update_stdlib_tests files(stdlibTestsZip)
|
|
||||||
updateTestData = false
|
|
||||||
} else {
|
|
||||||
println("WARNING: using stdlib tests provided by gradle.properties. Please execute :kotlin:zipTestData")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ext.testOutputRoot = rootProject.file("test.output").absolutePath
|
ext.testOutputRoot = rootProject.file("test.output").absolutePath
|
||||||
ext.externalTestsDir = project.file("build/external")
|
ext.externalTestsDir = project.file("build/external")
|
||||||
@@ -182,43 +164,6 @@ def installTestLib = tasks.register("installTestLibrary", KlibInstall) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets tests from the same Kotlin compiler build
|
|
||||||
def update_external_tests() {
|
|
||||||
// Copy only used tests into the test directory.
|
|
||||||
if (externalTestsDir.exists()) {
|
|
||||||
delete(externalTestsDir)
|
|
||||||
}
|
|
||||||
externalTestsDir.mkdirs()
|
|
||||||
|
|
||||||
def compilerTestsFiles = configurations.update_tests.asFileTree
|
|
||||||
copy {
|
|
||||||
compilerTestsFiles.each {
|
|
||||||
from(zipTree(it))
|
|
||||||
into(externalTestsDir)
|
|
||||||
include 'compiler/codegen/box/**'
|
|
||||||
include 'compiler/codegen/boxInline/**'
|
|
||||||
include 'compiler/compileKotlinAgainstKotlin/**'
|
|
||||||
include 'compiler/binaryCompatibility/klibEvolution/**'
|
|
||||||
exclude 'stdlib/**'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (externalStdlibTestsDir.exists()) {
|
|
||||||
delete(externalStdlibTestsDir)
|
|
||||||
}
|
|
||||||
externalStdlibTestsDir.mkdirs()
|
|
||||||
def stdlibTestsFiles = configurations.update_stdlib_tests.asFileTree
|
|
||||||
copy {
|
|
||||||
stdlibTestsFiles.each {
|
|
||||||
into(externalStdlibTestsDir)
|
|
||||||
include 'common/**'
|
|
||||||
include 'test/**'
|
|
||||||
exclude 'test/js/**'
|
|
||||||
include 'kotlin-test/**'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void konanc(String[] args) {
|
void konanc(String[] args) {
|
||||||
def konancScript = isWindows() ? "konanc.bat" : "konanc"
|
def konancScript = isWindows() ? "konanc.bat" : "konanc"
|
||||||
def konanc = "$dist/bin/$konancScript"
|
def konanc = "$dist/bin/$konancScript"
|
||||||
@@ -229,7 +174,7 @@ void konanc(String[] args) {
|
|||||||
|
|
||||||
clean {
|
clean {
|
||||||
doLast {
|
doLast {
|
||||||
delete(rootProject.file(testOutputRoot))
|
delete(project(":kotlin-native").file(testOutputRoot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,33 +248,13 @@ boolean isExcluded(String dir) {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
def createTestTasks(File testRoot, Class<Task> taskType) {
|
|
||||||
testRoot.eachDirRecurse {
|
|
||||||
// Skip build directory and directories without *.kt files.
|
|
||||||
if (it.name == "build" || it.listFiles().count { it.name.endsWith(".kt") && it.isFile() } == 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
def taskDirectory = project.relativePath(it).substring("build/".length())
|
|
||||||
if (!isExcluded(taskDirectory)) {
|
|
||||||
def taskName = taskDirectory.replaceAll("[-/\\\\]", '_')
|
|
||||||
project.tasks.register(taskName, taskType) {
|
|
||||||
it.groupDirectory = taskDirectory
|
|
||||||
it.finalizedBy resultsTask
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
println("$taskDirectory is excluded")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dependsOnPlatformLibs(Task t) {
|
void dependsOnPlatformLibs(Task t) {
|
||||||
if (!useCustomDist) {
|
if (!useCustomDist) {
|
||||||
def testTarget = project.target
|
def testTarget = project.target
|
||||||
if (testTarget != project.platformManager.Companion.host) {
|
if (testTarget != project.platformManager.Companion.host) {
|
||||||
t.dependsOn(":${testTarget}PlatformLibs")
|
t.dependsOn(":${testTarget}PlatformLibs")
|
||||||
} else {
|
} else {
|
||||||
t.dependsOn(':distPlatformLibs')
|
t.dependsOn(':kotlin-native:distPlatformLibs')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,14 +343,28 @@ Task dynamicTest(String name, Closure<KonanDynamicTest> configureClosure) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task run_external () {
|
def ignoredTests = [
|
||||||
// Set this property to disable auto update tests
|
"compiler_testData_codegen_box_callableReference" : ["genericConstructorReference.kt"]
|
||||||
if (!project.hasProperty("test.disable_update")) {
|
]
|
||||||
update_external_tests()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create tasks for external tests.
|
task run_external () {
|
||||||
createTestTasks(externalTestsDir, RunExternalTestGroup)
|
outputs.upToDateWhen{ false }
|
||||||
|
|
||||||
|
rootProject.files(
|
||||||
|
'compiler/testData/codegen/box',
|
||||||
|
'compiler/codegen/boxInline',
|
||||||
|
'compiler/compileKotlinAgainstKotlin'
|
||||||
|
).asFileTree.visit { file ->
|
||||||
|
if (!file.isDirectory() || !file.file.list().any{ it.endsWith(".kt")})
|
||||||
|
return
|
||||||
|
def taskPath = rootProject.relativePath(file.file)
|
||||||
|
def taskName = taskPath.split(System.properties["file.separator"]).join('_')
|
||||||
|
project.tasks.register(taskName, RunExternalTestGroup) {
|
||||||
|
it.groupDirectory = taskPath
|
||||||
|
it.finalizedBy resultsTask
|
||||||
|
it.ignoredTests = ignoredTests[taskName]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set up dependencies.
|
// Set up dependencies.
|
||||||
dependsOn(tasksOf(RunExternalTestGroup))
|
dependsOn(tasksOf(RunExternalTestGroup))
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ import java.util.function.Function
|
|||||||
import java.util.function.UnaryOperator
|
import java.util.function.UnaryOperator
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import java.util.stream.Collectors
|
import java.util.stream.Collectors
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
||||||
def platformManager = project.rootProject.platformManager
|
def platformManager = project.project(":kotlin-native").platformManager
|
||||||
def target = platformManager.targetManager(project.testTarget).target
|
def target = platformManager.targetManager(project.testTarget).target
|
||||||
def dist = UtilsKt.getKotlinNativeDist(project)
|
def dist = UtilsKt.getKotlinNativeDist(project)
|
||||||
|
|
||||||
@@ -206,12 +207,14 @@ class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
|||||||
@Input
|
@Input
|
||||||
def groupDirectory = "."
|
def groupDirectory = "."
|
||||||
|
|
||||||
|
def ignoredTests = []
|
||||||
|
|
||||||
String filter = project.findProperty("filter")
|
String filter = project.findProperty("filter")
|
||||||
|
|
||||||
def testGroupReporter = new KonanTestGroupReportEnvironment(project)
|
def testGroupReporter = new KonanTestGroupReportEnvironment(project)
|
||||||
|
|
||||||
void parseLanguageFlags(String src) {
|
void parseLanguageFlags(String src) {
|
||||||
def text = project.buildDir.toPath().resolve(src).text
|
def text = project.rootProject.file(src).text
|
||||||
def languageSettings = findLinesWithPrefixesRemoved(text, "// !LANGUAGE: ")
|
def languageSettings = findLinesWithPrefixesRemoved(text, "// !LANGUAGE: ")
|
||||||
if (languageSettings.size() != 0) {
|
if (languageSettings.size() != 0) {
|
||||||
languageSettings.forEach { line ->
|
languageSettings.forEach { line ->
|
||||||
@@ -269,14 +272,13 @@ class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
|||||||
def boxPattern = ~/(?m)fun\s+box\s*\(\s*\)/
|
def boxPattern = ~/(?m)fun\s+box\s*\(\s*\)/
|
||||||
def classPattern = ~/.*(class|object|enum|interface)\s+(${identifier}*).*/
|
def classPattern = ~/.*(class|object|enum|interface)\s+(${identifier}*).*/
|
||||||
|
|
||||||
def sourceName = "_" + normalize(project.buildDir.toPath().resolve(src).toFile().name)
|
def sourceName = "_" + normalize(project.rootProject.file(src).name)
|
||||||
def packages = new LinkedHashSet<String>()
|
def packages = new LinkedHashSet<String>()
|
||||||
def imports = []
|
def imports = []
|
||||||
def classes = []
|
def classes = []
|
||||||
def vars = new HashSet<String>() // variables that has the same name as a package
|
def vars = new HashSet<String>() // variables that has the same name as a package
|
||||||
TestModule mainModule = null
|
TestModule mainModule = null
|
||||||
|
def testFiles = TestDirectivesKt.buildCompileList(project.rootProject.file(src).toPath(), "$outputDirectory/${project.rootProject.file(src).name}")
|
||||||
def testFiles = TestDirectivesKt.buildCompileList(project.file("build/$src").toPath(), "$outputDirectory/$src")
|
|
||||||
for (TestFile testFile: testFiles) {
|
for (TestFile testFile: testFiles) {
|
||||||
def text = testFile.text
|
def text = testFile.text
|
||||||
def filePath = testFile.path
|
def filePath = testFile.path
|
||||||
@@ -299,7 +301,7 @@ class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find mutable objects that should be marked as ThreadLocal
|
// Find mutable objects that should be marked as ThreadLocal
|
||||||
if (filePath != "$outputDirectory/$src/helpers.kt") {
|
if (filePath != "$outputDirectory/${project.rootProject.file(src).name}/helpers.kt") {
|
||||||
text = markMutableObjects(text)
|
text = markMutableObjects(text)
|
||||||
}
|
}
|
||||||
testFile.text = text
|
testFile.text = text
|
||||||
@@ -369,13 +371,13 @@ class RunExternalTestGroup extends JavaExec implements CompilerRunner {
|
|||||||
testFile.text = res
|
testFile.text = res
|
||||||
}
|
}
|
||||||
def launcherText = createLauncherFileText(src, imports)
|
def launcherText = createLauncherFileText(src, imports)
|
||||||
testFiles.add(new TestFile("_launcher.kt", "$outputDirectory/$src/_launcher.kt".toString(),
|
testFiles.add(new TestFile("_launcher.kt", "$outputDirectory/${project.rootProject.file(src).name}/_launcher.kt".toString(),
|
||||||
launcherText, mainModule != null ? mainModule : TestModule.default))
|
launcherText, mainModule != null ? mainModule : TestModule.default))
|
||||||
return testFiles
|
return testFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
String normalize(String name) {
|
String normalize(String name) {
|
||||||
name.replace('.kt', '')
|
return name.replace('.kt', '')
|
||||||
.replace('-','_')
|
.replace('-','_')
|
||||||
.replace('.', '_')
|
.replace('.', '_')
|
||||||
}
|
}
|
||||||
@@ -415,18 +417,22 @@ fun runTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static def excludeList = [
|
static def excludeList = [
|
||||||
"external/compiler/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt", // KT-36880
|
"compiler/testData/codegen/boxInline/multiplatform/defaultArguments/receiversAndParametersInLambda.kt", // KT-36880
|
||||||
"external/compiler/compileKotlinAgainstKotlin/specialBridgesInDependencies.kt", // KT-42723
|
"compiler/testData/compileKotlinAgainstKotlin/specialBridgesInDependencies.kt", // KT-42723
|
||||||
"external/compiler/codegen/box/collections/kt41123.kt", // KT-42723
|
"compiler/testData/codegen/box/collections/kt41123.kt", // KT-42723
|
||||||
"external/compiler/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt", // KT-40137
|
"compiler/testData/codegen/box/multiplatform/multiModule/expectActualTypealiasLink.kt", // KT-40137
|
||||||
"external/compiler/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt", // KT-33091
|
"compiler/testData/codegen/box/multiplatform/multiModule/expectActualMemberLink.kt", // KT-33091
|
||||||
"external/compiler/codegen/box/multiplatform/multiModule/expectActualLink.kt", // KT-41901
|
"compiler/testData/codegen/box/multiplatform/multiModule/expectActualLink.kt", // KT-41901
|
||||||
"external/compiler/codegen/box/coroutines/multiModule/", // KT-40121
|
"compiler/testData/codegen/box/coroutines/multiModule/", // KT-40121
|
||||||
"external/compiler/codegen/box/defaultArguments/recursiveDefaultArguments.kt" // KT-42684
|
"compiler/testData/codegen/box/defaultArguments/recursiveDefaultArguments.kt" // KT-42684
|
||||||
]
|
]
|
||||||
|
|
||||||
boolean isEnabledForNativeBackend(String fileName) {
|
boolean isEnabledForNativeBackend(String fileName) {
|
||||||
def text = project.buildDir.toPath().resolve(fileName).text
|
def testFile = project.rootProject.file(fileName)
|
||||||
|
def text = testFile.text
|
||||||
|
|
||||||
|
if (testFile.name in ignoredTests)
|
||||||
|
return false
|
||||||
|
|
||||||
if (excludeList.any { fileName.replace(File.separator, "/").contains(it) }) return false
|
if (excludeList.any { fileName.replace(File.separator, "/").contains(it) }) return false
|
||||||
|
|
||||||
@@ -476,7 +482,7 @@ fun runTest() {
|
|||||||
void executeTest() {
|
void executeTest() {
|
||||||
createOutputDirectory()
|
createOutputDirectory()
|
||||||
// Form the test list.
|
// Form the test list.
|
||||||
List<File> ktFiles = project.buildDir.toPath().resolve(groupDirectory).toFile()
|
def ktFiles = project.rootProject.projectDir.toPath().resolve(groupDirectory).toFile()
|
||||||
.listFiles({
|
.listFiles({
|
||||||
it.isFile() && it.name.endsWith(".kt")
|
it.isFile() && it.name.endsWith(".kt")
|
||||||
} as FileFilter)
|
} as FileFilter)
|
||||||
@@ -492,10 +498,9 @@ fun runTest() {
|
|||||||
flags = (flags ?: []) + "-tr"
|
flags = (flags ?: []) + "-tr"
|
||||||
List<TestFile> compileList = []
|
List<TestFile> compileList = []
|
||||||
ktFiles.each {
|
ktFiles.each {
|
||||||
def src = project.buildDir.relativePath(it)
|
def src = project.rootProject.relativePath(it)
|
||||||
if (isEnabledForNativeBackend(src)) {
|
if (isEnabledForNativeBackend(src)) {
|
||||||
// Create separate output directory for each test in the group.
|
// Create separate output directory for each test in the group.
|
||||||
project.file("$outputDirectory/${it.name}").mkdirs()
|
|
||||||
parseLanguageFlags(src)
|
parseLanguageFlags(src)
|
||||||
compileList.addAll(createTestFiles(src))
|
compileList.addAll(createTestFiles(src))
|
||||||
}
|
}
|
||||||
@@ -543,7 +548,7 @@ fun runTest() {
|
|||||||
// Run the tests.
|
// Run the tests.
|
||||||
arguments = (arguments ?: []) + "--ktest_logger=SILENT"
|
arguments = (arguments ?: []) + "--ktest_logger=SILENT"
|
||||||
ktFiles.each { file ->
|
ktFiles.each { file ->
|
||||||
def src = project.buildDir.relativePath(file)
|
def src = project.rootProject.relativePath(file)
|
||||||
def savedArgs = arguments
|
def savedArgs = arguments
|
||||||
arguments += "--ktest_filter=_${normalize(file.name)}.*"
|
arguments += "--ktest_filter=_${normalize(file.name)}.*"
|
||||||
use(KonanTestSuiteReportKt) {
|
use(KonanTestSuiteReportKt) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.nio.file.Path
|
|||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.util.regex.Matcher
|
import java.util.regex.Matcher
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
private const val MODULE_DELIMITER = ",\\s*"
|
private const val MODULE_DELIMITER = ",\\s*"
|
||||||
// These patterns are copies from
|
// These patterns are copies from
|
||||||
|
|||||||
Reference in New Issue
Block a user