mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
Test fix.
This commit is contained in:
parent
5d5f8db24c
commit
981ba0729a
4 changed files with 29 additions and 14 deletions
|
@ -1,27 +1,19 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.app.BuildFileCompiler
|
||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.internal.KobaltPluginXml
|
||||
import com.beust.kobalt.internal.PluginInfo
|
||||
import com.beust.kobalt.internal.TaskManager
|
||||
import com.beust.kobalt.internal.build.BuildFile
|
||||
import com.beust.kobalt.maven.aether.KobaltAether
|
||||
import org.testng.annotations.BeforeClass
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
|
||||
open class BaseTest {
|
||||
val aether : KobaltAether get() = Kobalt.INJECTOR.getInstance(KobaltAether::class.java)
|
||||
val taskManager : TaskManager get() = Kobalt.INJECTOR.getInstance(TaskManager::class.java)
|
||||
val context = KobaltContext(Args())
|
||||
|
||||
@BeforeClass
|
||||
fun bc() {
|
||||
Kobalt.init(TestModule())
|
||||
context.aether = aether
|
||||
}
|
||||
|
||||
fun compileBuildFile(buildFileText: String, args: Args, compilerFactory: BuildFileCompiler.IFactory)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.google.inject.Inject
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.testng.annotations.DataProvider
|
||||
import org.testng.annotations.Guice
|
||||
|
@ -8,7 +9,7 @@ import org.testng.annotations.Test
|
|||
import java.io.File
|
||||
|
||||
@Guice(modules = arrayOf(TestModule::class))
|
||||
class ContextTest : BaseTest() {
|
||||
class ContextTest @Inject constructor(val context: KobaltContext) : BaseTest() {
|
||||
|
||||
val GROUP = "org.testng"
|
||||
val ARTIFACT = "testng"
|
||||
|
|
|
@ -1,20 +1,42 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.app.MainModule
|
||||
import com.beust.kobalt.internal.ILogger
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.internal.KobaltSettingsXml
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.maven.aether.Aether
|
||||
import com.beust.kobalt.maven.aether.KobaltAether
|
||||
import com.google.common.eventbus.EventBus
|
||||
import com.google.inject.Provider
|
||||
import com.google.inject.Scopes
|
||||
import java.io.File
|
||||
|
||||
val LOCAL_CACHE = File(SystemProperties.homeDir + File.separatorChar + ".kobalt-test")
|
||||
|
||||
val TEST_KOBALT_SETTINGS = KobaltSettings(KobaltSettingsXml()).apply {
|
||||
localCache = File(SystemProperties.homeDir + File.separatorChar + ".kobalt-test")
|
||||
localCache = LOCAL_CACHE
|
||||
}
|
||||
|
||||
class TestLocalRepo: LocalRepo(TEST_KOBALT_SETTINGS)
|
||||
|
||||
class TestModule : MainModule(Args(), TEST_KOBALT_SETTINGS) {
|
||||
override fun configureTest() {
|
||||
bind(LocalRepo::class.java).to(TestLocalRepo::class.java).`in`(Scopes.SINGLETON)
|
||||
val localRepo = TestLocalRepo()
|
||||
bind(LocalRepo::class.java).toInstance(localRepo)
|
||||
val localAether = Aether(LOCAL_CACHE, TEST_KOBALT_SETTINGS, EventBus())
|
||||
val testAether = KobaltAether(KobaltSettings(KobaltSettingsXml()), localAether)
|
||||
bind(KobaltAether::class.java).to(testAether)
|
||||
bind(KobaltContext::class.java).toProvider(Provider<KobaltContext> {
|
||||
KobaltContext(args).apply {
|
||||
aether = testAether
|
||||
logger = object: ILogger {
|
||||
override fun log(tag: CharSequence, level: Int, message: CharSequence, newLine: Boolean) {
|
||||
println("TestLog: [$tag $level] " + message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}).`in`(Scopes.SINGLETON)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.beust.kobalt.internal
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.TestConfig
|
||||
import com.beust.kobalt.TestModule
|
||||
import com.beust.kobalt.api.*
|
||||
|
@ -8,6 +7,7 @@ import com.beust.kobalt.maven.dependency.FileDependency
|
|||
import com.beust.kobalt.project
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.testng.annotations.BeforeClass
|
||||
import org.testng.annotations.Guice
|
||||
import org.testng.annotations.Test
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -15,14 +15,14 @@ import javax.inject.Inject
|
|||
/**
|
||||
* Test ITestJvmFlagContributor and ITestJvmFlagInterceptor.
|
||||
*/
|
||||
class DependencyTest @Inject constructor() {
|
||||
@Guice(modules = arrayOf(TestModule::class))
|
||||
class DependencyTest @Inject constructor(val context: KobaltContext) {
|
||||
private fun isWindows() = System.getProperty("os.name").toLowerCase().contains("ndows")
|
||||
private val A_JAR = if (isWindows()) "c:\\tmp\\a.jar" else "/tmp/a.jar"
|
||||
private val B_JAR = if (isWindows()) "c:\\tmp\\b.jar" else "/tmp/b.jar"
|
||||
|
||||
private val project : Project get() = project { name = "dummy" }
|
||||
private val classpath = listOf(FileDependency(A_JAR))
|
||||
private val context = KobaltContext(Args())
|
||||
private val contributor = object : ITestJvmFlagContributor {
|
||||
override fun testJvmFlagsFor(project: Project, context: KobaltContext,
|
||||
currentFlags: List<String>): List<String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue