mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-30 18:50:10 +08:00
Nested modules in console integration test
This commit is contained in:
parent
cf39a628a2
commit
884e7a3ee4
@ -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 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* 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")
|
@file:Suppress("UnusedImport")
|
||||||
@ -84,8 +84,8 @@ mcit_test.configure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val crtProject = project
|
val crtProject = project
|
||||||
subprojects {
|
allprojects {
|
||||||
if (project.parent == crtProject) {
|
if (project != crtProject) {
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
val tk = tasks.named<Jar>("jar")
|
val tk = tasks.named<Jar>("jar")
|
||||||
subplugins.add(tk)
|
subplugins.add(tk)
|
||||||
|
@ -24,7 +24,9 @@ import org.objectweb.asm.ClassWriter
|
|||||||
import org.objectweb.asm.Opcodes
|
import org.objectweb.asm.Opcodes
|
||||||
import org.objectweb.asm.Type
|
import org.objectweb.asm.Type
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileDescriptor
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
import java.io.PrintStream
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque
|
import java.util.concurrent.ConcurrentLinkedDeque
|
||||||
import java.util.zip.ZipEntry
|
import java.util.zip.ZipEntry
|
||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
@ -66,13 +68,22 @@ internal fun main() {
|
|||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
File("plugins").mkdirs()
|
File("plugins").mkdirs()
|
||||||
|
File("modules").mkdirs()
|
||||||
prepareConsole()
|
prepareConsole()
|
||||||
|
|
||||||
testUnits.forEach { (it as? AbstractTestPointAsPlugin)?.generatePluginJar() }
|
testUnits.forEach { (it as? AbstractTestPointAsPlugin)?.generatePluginJar() }
|
||||||
testUnits.forEach { it.internalBCS() }
|
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) {
|
if (!MiraiConsole.isActive) {
|
||||||
error("Failed to start console")
|
error("Failed to start console")
|
||||||
}
|
}
|
||||||
@ -107,10 +118,17 @@ loggers:
|
|||||||
|
|
||||||
readStringListFromEnv("IT_PLUGINS").forEach { path ->
|
readStringListFromEnv("IT_PLUGINS").forEach { path ->
|
||||||
val jarFile = File(path)
|
val jarFile = File(path)
|
||||||
|
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()
|
val target = File("plugins/${jarFile.name}").mkparents()
|
||||||
jarFile.copyTo(target, overwrite = true)
|
jarFile.copyTo(target, overwrite = true)
|
||||||
println("[MCIT] Copied external plugin: $jarFile")
|
println("[MCIT] Copied external plugin: $jarFile")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun AbstractTestPointAsPlugin.generatePluginJar() {
|
private fun AbstractTestPointAsPlugin.generatePluginJar() {
|
||||||
|
@ -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 许可证的约束, 可以在以下链接找到该许可证.
|
* 此源代码的使用受 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.
|
* 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")
|
@file:Suppress("UnusedImport")
|
||||||
|
@ -64,20 +64,24 @@ val consoleIntegrationTestSubPluginBuildGradleKtsTemplate by lazy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("SimpleRedundantLet")
|
@Suppress("SimpleRedundantLet")
|
||||||
fun includeConsoleITPlugin(path: File) {
|
fun includeConsoleITPlugin(prefix: String, path: File) {
|
||||||
path.resolve("build.gradle.kts").takeIf { !it.isFile }?.let { initScript ->
|
path.resolve("build.gradle.kts").takeIf { !it.isFile }?.let { initScript ->
|
||||||
initScript.writeText(consoleIntegrationTestSubPluginBuildGradleKtsTemplate)
|
initScript.writeText(consoleIntegrationTestSubPluginBuildGradleKtsTemplate)
|
||||||
}
|
}
|
||||||
|
|
||||||
val projectPath = ":mirai-console.integration-test:${path.name}"
|
val projectPath = "$prefix${path.name}"
|
||||||
include(projectPath)
|
include(projectPath)
|
||||||
project(projectPath).projectDir = path
|
project(projectPath).projectDir = path
|
||||||
|
path.listFiles()?.asSequence().orEmpty()
|
||||||
|
.filter { it.isDirectory }
|
||||||
|
.filter { it.resolve(".nested-module.txt").exists() }
|
||||||
|
.forEach { includeConsoleITPlugin("${projectPath}:", it) }
|
||||||
}
|
}
|
||||||
rootProject.projectDir
|
rootProject.projectDir
|
||||||
.resolve("mirai-console/backend/integration-test/testers")
|
.resolve("mirai-console/backend/integration-test/testers")
|
||||||
.listFiles()?.asSequence().orEmpty()
|
.listFiles()?.asSequence().orEmpty()
|
||||||
.filter { it.isDirectory }
|
.filter { it.isDirectory }
|
||||||
.forEach { includeConsoleITPlugin(it) }
|
.forEach { includeConsoleITPlugin(":mirai-console.integration-test:", it) }
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
includeConsoleProject(":mirai-console-compiler-common", "tools/compiler-common")
|
includeConsoleProject(":mirai-console-compiler-common", "tools/compiler-common")
|
||||||
|
Loading…
Reference in New Issue
Block a user