mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -07:00
fix test assertion, enable kobalt logging for tests
This commit is contained in:
parent
39801a5a24
commit
7cf19b3f95
4 changed files with 19 additions and 11 deletions
|
@ -51,7 +51,7 @@ fun Any.error(text: CharSequence, e: Throwable? = null) {
|
|||
|
||||
object KobaltLogger {
|
||||
var LOG_LEVEL: Int = 1
|
||||
|
||||
|
||||
val isQuiet: Boolean get() = (LOG_LEVEL == Constants.LOG_QUIET_LEVEL)
|
||||
|
||||
val logger: Logger get() =
|
||||
|
@ -60,6 +60,14 @@ object KobaltLogger {
|
|||
} else {
|
||||
Logger(false)
|
||||
}
|
||||
|
||||
fun setLogLevel(args: Args) {
|
||||
LOG_LEVEL = when {
|
||||
args.log < Constants.LOG_QUIET_LEVEL -> Constants.LOG_DEFAULT_LEVEL
|
||||
args.log > Constants.LOG_MAX_LEVEL -> Constants.LOG_MAX_LEVEL
|
||||
else -> args.log
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Logger(val dev: Boolean) {
|
||||
|
|
|
@ -55,11 +55,7 @@ class Main @Inject constructor(
|
|||
val args = Args()
|
||||
val result = JCommander(args)
|
||||
result.parse(*argv)
|
||||
KobaltLogger.LOG_LEVEL = if (args.log < Constants.LOG_QUIET_LEVEL) {
|
||||
Constants.LOG_DEFAULT_LEVEL
|
||||
} else if (args.log > Constants.LOG_MAX_LEVEL) {
|
||||
Constants.LOG_MAX_LEVEL
|
||||
} else args.log
|
||||
KobaltLogger.setLogLevel(args)
|
||||
return Main.RunInfo(result, args)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.beust.kobalt.internal.KobaltPluginXml
|
|||
import com.beust.kobalt.internal.PluginInfo
|
||||
import com.beust.kobalt.internal.build.SingleFileBuildSources
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltLogger
|
||||
import com.beust.kobalt.misc.log
|
||||
import org.testng.annotations.BeforeClass
|
||||
import org.testng.annotations.Guice
|
||||
|
@ -121,6 +122,9 @@ open class BaseTest(val compilerFactory: BuildFileCompiler.IFactory? = null) {
|
|||
val main = Kobalt.INJECTOR.getInstance(Main::class.java)
|
||||
val args = Args()
|
||||
val jc = JCommander(args).apply { parse(*commandLine) }
|
||||
|
||||
KobaltLogger.setLogLevel(args)
|
||||
|
||||
args.buildFile = KFiles.fixSlashes(project.file.absolutePath) + "/kobalt/src/Build.kt"
|
||||
val result = Main.launchMain(main, jc, args, arrayOf("assemble"))
|
||||
return LaunchProjectResult(project, result)
|
||||
|
|
|
@ -19,7 +19,6 @@ class KotlinCompilerVersionTest : BaseTest() {
|
|||
"""
|
||||
kotlinCompiler {
|
||||
version = "1.2.60"
|
||||
args("-jvm-target", "1.8")
|
||||
}
|
||||
assemble{ jar{} }
|
||||
"""
|
||||
|
@ -30,7 +29,7 @@ class KotlinCompilerVersionTest : BaseTest() {
|
|||
)
|
||||
)
|
||||
|
||||
val result = launchProject(projectInfo, arrayOf("assemble"))
|
||||
val result = launchProject(projectInfo, arrayOf("assemble", "--log", "2"))
|
||||
|
||||
val project = result.projectDescription
|
||||
val jarFile = File(KFiles.joinDir(project.file.absolutePath, "kobaltBuild/libs", project.name + "-"
|
||||
|
@ -49,10 +48,11 @@ class KotlinCompilerVersionTest : BaseTest() {
|
|||
assemble{ jar{} }
|
||||
"""
|
||||
),
|
||||
listOf(ProjectFile("src/main/kotlin/A.kt", "val a = \"foo\"")))
|
||||
listOf(ProjectFile("src/main/kotlin/A.kt", "val a = \"foo\""))
|
||||
)
|
||||
|
||||
val result = launchProject(projectInfo, arrayOf("assemble"))
|
||||
val result = launchProject(projectInfo, arrayOf("assemble", "--log", "2"))
|
||||
|
||||
assertThat(result).isEqualTo(1)
|
||||
assertThat(result.result).isEqualTo(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue