mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -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
|
@ -60,6 +60,14 @@ object KobaltLogger {
|
||||||
} else {
|
} else {
|
||||||
Logger(false)
|
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) {
|
class Logger(val dev: Boolean) {
|
||||||
|
|
|
@ -55,11 +55,7 @@ class Main @Inject constructor(
|
||||||
val args = Args()
|
val args = Args()
|
||||||
val result = JCommander(args)
|
val result = JCommander(args)
|
||||||
result.parse(*argv)
|
result.parse(*argv)
|
||||||
KobaltLogger.LOG_LEVEL = if (args.log < Constants.LOG_QUIET_LEVEL) {
|
KobaltLogger.setLogLevel(args)
|
||||||
Constants.LOG_DEFAULT_LEVEL
|
|
||||||
} else if (args.log > Constants.LOG_MAX_LEVEL) {
|
|
||||||
Constants.LOG_MAX_LEVEL
|
|
||||||
} else args.log
|
|
||||||
return Main.RunInfo(result, 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.PluginInfo
|
||||||
import com.beust.kobalt.internal.build.SingleFileBuildSources
|
import com.beust.kobalt.internal.build.SingleFileBuildSources
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
import com.beust.kobalt.misc.KobaltLogger
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import org.testng.annotations.BeforeClass
|
import org.testng.annotations.BeforeClass
|
||||||
import org.testng.annotations.Guice
|
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 main = Kobalt.INJECTOR.getInstance(Main::class.java)
|
||||||
val args = Args()
|
val args = Args()
|
||||||
val jc = JCommander(args).apply { parse(*commandLine) }
|
val jc = JCommander(args).apply { parse(*commandLine) }
|
||||||
|
|
||||||
|
KobaltLogger.setLogLevel(args)
|
||||||
|
|
||||||
args.buildFile = KFiles.fixSlashes(project.file.absolutePath) + "/kobalt/src/Build.kt"
|
args.buildFile = KFiles.fixSlashes(project.file.absolutePath) + "/kobalt/src/Build.kt"
|
||||||
val result = Main.launchMain(main, jc, args, arrayOf("assemble"))
|
val result = Main.launchMain(main, jc, args, arrayOf("assemble"))
|
||||||
return LaunchProjectResult(project, result)
|
return LaunchProjectResult(project, result)
|
||||||
|
|
|
@ -19,7 +19,6 @@ class KotlinCompilerVersionTest : BaseTest() {
|
||||||
"""
|
"""
|
||||||
kotlinCompiler {
|
kotlinCompiler {
|
||||||
version = "1.2.60"
|
version = "1.2.60"
|
||||||
args("-jvm-target", "1.8")
|
|
||||||
}
|
}
|
||||||
assemble{ jar{} }
|
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 project = result.projectDescription
|
||||||
val jarFile = File(KFiles.joinDir(project.file.absolutePath, "kobaltBuild/libs", project.name + "-"
|
val jarFile = File(KFiles.joinDir(project.file.absolutePath, "kobaltBuild/libs", project.name + "-"
|
||||||
|
@ -49,10 +48,11 @@ class KotlinCompilerVersionTest : BaseTest() {
|
||||||
assemble{ jar{} }
|
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