Skip to content

Commit a52e6fc

Browse files
committed
Make output less noisy #16
1 parent 215c608 commit a52e6fc

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/main/kotlin/com/tschuchort/compiletesting/KotlinCompilation.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class KotlinCompilation {
9696
var allWarningsAsErrors: Boolean = false
9797

9898
/** Report locations of files generated by the compiler */
99-
var reportOutputFiles: Boolean = verbose
99+
var reportOutputFiles: Boolean by default { verbose }
100100

101101
/** Report on performance of the compilation */
102102
var reportPerformance: Boolean = false
@@ -213,7 +213,7 @@ class KotlinCompilation {
213213
* (on JDK8) or --system none (on JDK9+). This can be useful if all
214214
* the JDK classes you need are already on the (inherited) classpath.
215215
* */
216-
var jdkHome: File? = getJdkHome()
216+
var jdkHome: File? by default { getJdkHome() }
217217

218218
/**
219219
* Path to the kotlin-stdlib.jar
@@ -399,7 +399,6 @@ class KotlinCompilation {
399399
it.allWarningsAsErrors = allWarningsAsErrors
400400
it.reportOutputFiles = reportOutputFiles
401401
it.reportPerf = reportPerformance
402-
it.reportOutputFiles = reportOutputFiles
403402
}
404403

405404
/** Performs the 1st and 2nd compilation step to generate stubs and run annotation processors */
@@ -420,7 +419,9 @@ class KotlinCompilation {
420419
}
421420

422421
it.mode = AptMode.STUBS_AND_APT
423-
it.flags.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
422+
423+
if (verbose)
424+
it.flags.addAll(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS, KaptFlag.VERBOSE)
424425
}
425426

426427
/* The kapt compiler plugin (KaptComponentRegistrar)
@@ -474,13 +475,12 @@ class KotlinCompilation {
474475

475476
val k2JvmArgs = commonK2JVMArgs().also {
476477
it.freeArgs = sourcePaths
477-
478478
it.pluginClasspaths = (it.pluginClasspaths?.toList() ?: emptyList<String>() + getResourcesPath())
479479
.distinct().toTypedArray()
480480
}
481481

482482
val compilerMessageCollector = PrintingMessageCollector(
483-
internalMessageStream, MessageRenderer.WITHOUT_PATHS, true
483+
internalMessageStream, MessageRenderer.GRADLE_STYLE, verbose
484484
)
485485

486486
return convertKotlinExitCode(
@@ -522,7 +522,7 @@ class KotlinCompilation {
522522
}
523523

524524
val compilerMessageCollector = PrintingMessageCollector(
525-
internalMessageStream, MessageRenderer.WITHOUT_PATHS, true
525+
internalMessageStream, MessageRenderer.GRADLE_STYLE, verbose
526526
)
527527

528528
return convertKotlinExitCode(

src/test/kotlin/com/tschuchort/compiletesting/KotlinCompilationTests.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class KotlinCompilationTests {
120120
}.compile()
121121

122122
assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR)
123-
assertThat(result.messages).contains("unresolved reference: java")
123+
assertThat(result.messages).containsIgnoringCase("unresolved reference: java")
124124
}
125125

126126
@Test
@@ -262,7 +262,7 @@ class KotlinCompilationTests {
262262
}.compile()
263263

264264
assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR)
265-
assertThat(result.messages).contains("unresolved reference: KotlinCompilationTests")
265+
assertThat(result.messages).containsIgnoringCase("unresolved reference: KotlinCompilationTests")
266266
}
267267

268268
@Test
@@ -630,7 +630,7 @@ class KotlinCompilationTests {
630630
skipRuntimeVersionCheck = true
631631
correctErrorTypes = true
632632
verbose = true
633-
reportOutputFiles = true
633+
reportOutputFiles = false
634634
messageOutputStream = System.out
635635
}
636636
}

0 commit comments

Comments
 (0)