From 6253ceec9246d73b66bfdf7354275484dd194d8f Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Wed, 11 Oct 2017 12:17:58 +0200 Subject: [PATCH] Reproduce problem where error disappeared When the javadoc tool fails with an error that could not be parsed, the error is silently dropped. --- .../inc/javac/CollectingReporter.scala | 19 ++++++++++++++++++ .../inc/javac/JavacProcessLoggerSpec.scala | 20 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/CollectingReporter.scala create mode 100644 internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/JavacProcessLoggerSpec.scala diff --git a/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/CollectingReporter.scala b/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/CollectingReporter.scala new file mode 100644 index 0000000000..4c2d6e8899 --- /dev/null +++ b/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/CollectingReporter.scala @@ -0,0 +1,19 @@ +package sbt +package internal +package inc +package javac + +import xsbti.Reporter +import xsbti.Problem + +class CollectingReporter extends Reporter { + var problems: Array[Problem] = Array[Problem]() + + def reset() = problems = Array[Problem]() + def hasErrors() = ??? + def hasWarnings(): Boolean = ??? + def printSummary(): Unit = ??? + def log(problem: xsbti.Problem): Unit = problems :+= problem + def comment(pos: xsbti.Position, msg: String): Unit = ??? + +} \ No newline at end of file diff --git a/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/JavacProcessLoggerSpec.scala b/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/JavacProcessLoggerSpec.scala new file mode 100644 index 0000000000..b222c88caf --- /dev/null +++ b/internal/zinc-compile-core/src/test/scala/sbt/internal/inc/javac/JavacProcessLoggerSpec.scala @@ -0,0 +1,20 @@ +package sbt +package internal +package inc +package javac + +import java.io.File + +class JavaProcessLoggerSpec extends UnitSpec { + "The javac process logger" should "log errors that could not be parsed" in logUnparsableErrors() + + def logUnparsableErrors() = { + val reporter = new CollectingReporter() + val logger = new JavacLogger(log = null, reporter, cwd = new File(".")) + logger.err("javadoc: error - invalid flag: -target") + + logger.flush(-1) + + reporter.problems.length should be(1) + } +} \ No newline at end of file