MiraiConsoleIntegrationTestBootstrap.kt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2019-2021 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/dev/LICENSE
  8. */
  9. package net.mamoe.console.integrationtest
  10. import net.mamoe.console.integrationtest.testpoints.DoNothingPoint
  11. import net.mamoe.console.integrationtest.testpoints.MCITBSelfAssertions
  12. import net.mamoe.console.integrationtest.testpoints.PluginSharedLibraries
  13. import net.mamoe.console.integrationtest.testpoints.plugin.PluginDataRenameToIdTest
  14. import net.mamoe.console.integrationtest.testpoints.terminal.TestTerminalLogging
  15. import org.junit.jupiter.api.Test
  16. import java.io.File
  17. import java.lang.management.ManagementFactory
  18. import java.util.*
  19. import kotlin.reflect.KClass
  20. class MiraiConsoleIntegrationTestBootstrap {
  21. @Test
  22. fun bootstrap() {
  23. /*
  24. implementation note:
  25. 不使用 @TempDir 是为了保存最后一次失败快照, 便于 debug
  26. */
  27. val workingDir = File("build/IntegrationTest") // mirai-console/backend/integration-test/build/IntegrationTest
  28. val launcher = MiraiConsoleIntegrationTestLauncher()
  29. launcher.workingDir = workingDir
  30. launcher.plugins = readStringListFromEnv("IT_PLUGINS")
  31. launcher.points = listOf<Any>(
  32. DoNothingPoint,
  33. MCITBSelfAssertions,
  34. PluginDataRenameToIdTest,
  35. TestTerminalLogging,
  36. PluginSharedLibraries,
  37. ).asSequence().map { v ->
  38. when (v) {
  39. is Class<*> -> v
  40. is KClass<*> -> v.java
  41. else -> v.javaClass
  42. }
  43. }.map { it.name }.toMutableList()
  44. launcher.vmoptions = mutableListOf(
  45. *ManagementFactory.getRuntimeMXBean().inputArguments.filterNot {
  46. it.startsWith("-Djava.security.manager=")
  47. }.toTypedArray(),
  48. *System.getenv("IT_ARGS")!!.splitToSequence(",").map {
  49. Base64.getDecoder().decode(it).decodeToString()
  50. }.filter { it.isNotEmpty() }.toList().toTypedArray()
  51. )
  52. launcher.launch()
  53. }
  54. }