1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Don't need BaseTest.

This commit is contained in:
Cedric Beust 2016-07-25 03:21:37 -08:00
parent 2ea5a6100b
commit d5a21c2c1a
2 changed files with 20 additions and 27 deletions

View file

@ -1,16 +1,8 @@
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.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(open val aether: KobaltAether) {
val context = KobaltContext(Args())
@ -19,19 +11,4 @@ open class BaseTest(open val aether: KobaltAether) {
fun bc() {
context.aether = aether
}
fun compileBuildFile(buildFileText: String, args: Args, compilerFactory: BuildFileCompiler.IFactory)
: BuildFileCompiler.FindProjectResult {
val tmpBuildFile = File.createTempFile("kobaltTest", "").apply {
deleteOnExit()
writeText(buildFileText)
}
val thisBuildFile = BuildFile(Paths.get(tmpBuildFile.absolutePath), "Build.kt")
args.buildFile = tmpBuildFile.absolutePath
val jvmCompilerPlugin = Kobalt.findPlugin("JvmCompiler") as JvmCompilerPlugin
val pluginInfo = PluginInfo(KobaltPluginXml(), null, null).apply {
projectContributors.add(jvmCompilerPlugin)
}
return compilerFactory.create(listOf(thisBuildFile), pluginInfo).compileBuildFiles(args)
}
}

View file

@ -1,20 +1,36 @@
package com.beust.kobalt.internal
import com.beust.kobalt.Args
import com.beust.kobalt.BaseTest
import com.beust.kobalt.TestModule
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.Project
import com.beust.kobalt.app.BuildFileCompiler
import com.beust.kobalt.maven.aether.KobaltAether
import com.beust.kobalt.internal.build.BuildFile
import com.google.inject.Inject
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Guice
import org.testng.annotations.Test
import java.io.File
import java.nio.file.Paths
@Guice(modules = arrayOf(TestModule::class))
class ProfileTest @Inject constructor(val compilerFactory: BuildFileCompiler.IFactory,
override val aether: KobaltAether): BaseTest(aether) {
class ProfileTest @Inject constructor(val compilerFactory: BuildFileCompiler.IFactory) {
private fun compileBuildFile(buildFileText: String, args: Args, compilerFactory: BuildFileCompiler.IFactory)
: BuildFileCompiler.FindProjectResult {
val tmpBuildFile = File.createTempFile("kobaltTest", "").apply {
deleteOnExit()
writeText(buildFileText)
}
val thisBuildFile = BuildFile(Paths.get(tmpBuildFile.absolutePath), "Build.kt")
args.buildFile = tmpBuildFile.absolutePath
val jvmCompilerPlugin = Kobalt.findPlugin("JvmCompiler") as JvmCompilerPlugin
val pluginInfo = PluginInfo(KobaltPluginXml(), null, null).apply {
projectContributors.add(jvmCompilerPlugin)
}
return compilerFactory.create(listOf(thisBuildFile), pluginInfo).compileBuildFiles(args)
}
private fun runTestWithProfile(enabled: Boolean) : Project {
val buildFileString = """
| import com.beust.kobalt.*