From 3d689b3367df182d0dc37305ef1173548de1c947 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 14 Mar 2017 20:21:32 -0700 Subject: [PATCH] Better test failure message. --- src/test/kotlin/com/beust/kobalt/BaseTest.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/com/beust/kobalt/BaseTest.kt b/src/test/kotlin/com/beust/kobalt/BaseTest.kt index 9f82990d..bfcdf095 100644 --- a/src/test/kotlin/com/beust/kobalt/BaseTest.kt +++ b/src/test/kotlin/com/beust/kobalt/BaseTest.kt @@ -34,8 +34,15 @@ open class BaseTest(val compilerFactory: BuildFileCompiler.IFactory? = null) { } """ + args.noIncremental = true val projectResults = compileBuildFile(buildFileText, args) - return projectResults.projects.first { it.name == projectName } + val result = projectResults.projects.firstOrNull { it.name == projectName } + if (result == null) { + throw IllegalArgumentException("Couldn't find project named $projectName in " + + projectResults.projects.map { it.name }.joinToString(", ", "[", "]")) + } else { + return result + } } /** @@ -52,6 +59,8 @@ open class BaseTest(val compilerFactory: BuildFileCompiler.IFactory? = null) { val thisBuildFile = BuildFile(Paths.get(tmpBuildFile.absolutePath), "Build.kt") args.apply { buildFile = tmpBuildFile.absolutePath + noIncremental = true + noIncrementalKotlin = true } val jvmCompilerPlugin = Kobalt.findPlugin("JvmCompiler") as JvmCompilerPlugin val pluginInfo = PluginInfo(KobaltPluginXml(), null, null).apply {