Nested modules in console integration test

This commit is contained in:
Karlatemp 2022-03-11 17:58:37 +08:00
parent cf39a628a2
commit 884e7a3ee4
No known key found for this signature in database
GPG Key ID: C6B606FF23D8FED7
4 changed files with 39 additions and 17 deletions

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("UnusedImport")
@ -84,8 +84,8 @@ mcit_test.configure {
}
val crtProject = project
subprojects {
if (project.parent == crtProject) {
allprojects {
if (project != crtProject) {
project.afterEvaluate {
val tk = tasks.named<Jar>("jar")
subplugins.add(tk)

View File

@ -24,7 +24,9 @@ import org.objectweb.asm.ClassWriter
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import java.io.File
import java.io.FileDescriptor
import java.io.FileOutputStream
import java.io.PrintStream
import java.util.concurrent.ConcurrentLinkedDeque
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
@ -66,13 +68,22 @@ internal fun main() {
.toList()
File("plugins").mkdirs()
File("modules").mkdirs()
prepareConsole()
testUnits.forEach { (it as? AbstractTestPointAsPlugin)?.generatePluginJar() }
testUnits.forEach { it.internalBCS() }
MiraiConsoleTerminalLoader.startAsDaemon()
Thread.sleep(2000L)
try {
MiraiConsoleTerminalLoader.startAsDaemon()
} catch (e: Throwable) {
val ps = PrintStream(FileOutputStream(FileDescriptor.out))
e.printStackTrace(ps)
ps.flush()
exitProcess(1)
}
if (!MiraiConsole.isActive) {
error("Failed to start console")
}
@ -107,9 +118,16 @@ loggers:
readStringListFromEnv("IT_PLUGINS").forEach { path ->
val jarFile = File(path)
val target = File("plugins/${jarFile.name}").mkparents()
jarFile.copyTo(target, overwrite = true)
println("[MCIT] Copied external plugin: $jarFile")
if (jarFile.name.startsWith("module-")) {
// DYN MODULE
val target = File("modules/${jarFile.name}").mkparents()
jarFile.copyTo(target, overwrite = true)
println("[MCIT] Copied module: $jarFile")
} else {
val target = File("plugins/${jarFile.name}").mkparents()
jarFile.copyTo(target, overwrite = true)
println("[MCIT] Copied external plugin: $jarFile")
}
}
}

View File

@ -1,10 +1,10 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
* Copyright 2019-2022 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
* https://github.com/mamoe/mirai/blob/dev/LICENSE
*/
@file:Suppress("UnusedImport")

View File

@ -64,20 +64,24 @@ val consoleIntegrationTestSubPluginBuildGradleKtsTemplate by lazy {
}
@Suppress("SimpleRedundantLet")
fun includeConsoleITPlugin(path: File) {
fun includeConsoleITPlugin(prefix: String, path: File) {
path.resolve("build.gradle.kts").takeIf { !it.isFile }?.let { initScript ->
initScript.writeText(consoleIntegrationTestSubPluginBuildGradleKtsTemplate)
}
val projectPath = ":mirai-console.integration-test:${path.name}"
val projectPath = "$prefix${path.name}"
include(projectPath)
project(projectPath).projectDir = path
path.listFiles()?.asSequence().orEmpty()
.filter { it.isDirectory }
.filter { it.resolve(".nested-module.txt").exists() }
.forEach { includeConsoleITPlugin("${projectPath}:", it) }
}
rootProject.projectDir
.resolve("mirai-console/backend/integration-test/testers")
.listFiles()?.asSequence().orEmpty()
.filter { it.isDirectory }
.forEach { includeConsoleITPlugin(it) }
.forEach { includeConsoleITPlugin(":mirai-console.integration-test:", it) }
// endregion
includeConsoleProject(":mirai-console-compiler-common", "tools/compiler-common")