Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Report more errors on invalid .flags files #46

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/main/scala/scala/tools/partest/nest/DirectCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package scala.tools.partest
package nest

import scala.collection.mutable.ListBuffer
import scala.tools.nsc.{ Global, Settings, CompilerCommand, FatalError }
import scala.tools.nsc.reporters.{ Reporter, ConsoleReporter }
import scala.tools.nsc.util.{ FakePos, stackTraceString }
Expand All @@ -19,8 +20,6 @@ class ExtConsoleReporter(settings: Settings, val writer: PrintWriter) extends Co
}

class TestSettings(cp: String, error: String => Unit) extends Settings(error) {
def this(cp: String) = this(cp, _ => ())

nowarnings.value = false
encoding.value = "UTF-8"
classpath.value = cp
Expand Down Expand Up @@ -82,7 +81,9 @@ class DirectCompiler(val runner: Runner) {

val classPath: List[Path] = specializedOverride ++ codeLib ++ fileManager.testClassPath ++ List[Path](outDir)

val testSettings = new TestSettings(FileManager.joinPaths(classPath))
val parseArgErrors = ListBuffer.empty[String]

val testSettings = new TestSettings(FileManager.joinPaths(classPath), s => parseArgErrors += s)
val logWriter = new FileWriter(logFile)
val srcDir = if (testFile.isDirectory) testFile else Path(testFile).parent.jfile
val opts = updatePluginPath(opts0, AbstractFile getDirectory outDir, AbstractFile getDirectory srcDir)
Expand All @@ -93,9 +94,15 @@ class DirectCompiler(val runner: Runner) {

testSettings.outputDirs setSingleOutput outDir.getPath

def reportError(s: String): Unit = reporter.error(null, s)

parseArgErrors.toList foreach reportError

// check that option processing succeeded
if (opts0.nonEmpty && !command.ok)
reporter.error(null, opts0.mkString("bad options: ", space, ""))
if (opts0.nonEmpty) {
if (!command.ok) reportError(opts0.mkString("bad options: ", space, ""))
if (command.files.nonEmpty) reportError(command.files.mkString("flags file may only contain compiler options, found: ", space, ""))
}

def ids = sources.map(_.testIdent) mkString space
vlog(s"% scalac $ids")
Expand All @@ -115,7 +122,7 @@ class DirectCompiler(val runner: Runner) {
}

try { execCompile() }
catch { case t: Throwable => reporter.error(null, t.getMessage) ; runner.genCrash(t) }
catch { case t: Throwable => reportError(t.getMessage) ; runner.genCrash(t) }
finally { logWriter.close() }
}
}