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

Commit 44bc639

Browse files
committed
Merge pull request #46 from lrytz/flagsFileReport
Report more errors on invalid .flags files
2 parents c4ab64f + 28b4cb7 commit 44bc639

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main/scala/scala/tools/partest/nest/DirectCompiler.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package scala.tools.partest
77
package nest
88

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

2122
class TestSettings(cp: String, error: String => Unit) extends Settings(error) {
22-
def this(cp: String) = this(cp, _ => ())
23-
2423
nowarnings.value = false
2524
encoding.value = "UTF-8"
2625
classpath.value = cp
@@ -82,7 +81,9 @@ class DirectCompiler(val runner: Runner) {
8281

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

85-
val testSettings = new TestSettings(FileManager.joinPaths(classPath))
84+
val parseArgErrors = ListBuffer.empty[String]
85+
86+
val testSettings = new TestSettings(FileManager.joinPaths(classPath), s => parseArgErrors += s)
8687
val logWriter = new FileWriter(logFile)
8788
val srcDir = if (testFile.isDirectory) testFile else Path(testFile).parent.jfile
8889
val opts = updatePluginPath(opts0, AbstractFile getDirectory outDir, AbstractFile getDirectory srcDir)
@@ -93,9 +94,15 @@ class DirectCompiler(val runner: Runner) {
9394

9495
testSettings.outputDirs setSingleOutput outDir.getPath
9596

97+
def reportError(s: String): Unit = reporter.error(null, s)
98+
99+
parseArgErrors.toList foreach reportError
100+
96101
// check that option processing succeeded
97-
if (opts0.nonEmpty && !command.ok)
98-
reporter.error(null, opts0.mkString("bad options: ", space, ""))
102+
if (opts0.nonEmpty) {
103+
if (!command.ok) reportError(opts0.mkString("bad options: ", space, ""))
104+
if (command.files.nonEmpty) reportError(command.files.mkString("flags file may only contain compiler options, found: ", space, ""))
105+
}
99106

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

117124
try { execCompile() }
118-
catch { case t: Throwable => reporter.error(null, t.getMessage) ; runner.genCrash(t) }
125+
catch { case t: Throwable => reportError(t.getMessage) ; runner.genCrash(t) }
119126
finally { logWriter.close() }
120127
}
121128
}

0 commit comments

Comments
 (0)