From a07df6427f37849f9fc9456acc937082919b23d6 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Tue, 1 Mar 2011 18:29:40 +0000 Subject: Long overdue rehaul of presentation compiler te... Long overdue rehaul of presentation compiler tests. Added support for options file, and switched simple-tests to use the STARR library on the test classpath. Put any options you need passed to the presentation compiler in a file with the same name as the test, ending in '.opts'. Currently it's used to set the -bootclasspath for simple-tests. Check the contents of simple-tests.opts for all the options. IMPORTANT: when committing a new STARR, you need to check this test. Most likely, you *will* break it otherwise. review by extempore --- .../nsc/interactive/tests/InteractiveTest.scala | 40 ++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala index 4345c83014..a00fd44ed3 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/InteractiveTest.scala @@ -43,18 +43,46 @@ abstract class InteractiveTest { val settings = new Settings val reporter= new StoreReporter - // need this so that the classpath comes from what partest - // instead of scala.home - settings.usejavacp.value = true - /** The root directory for this test suite, usually the test kind ("test/files/presentation"). */ val outDir = Path(Option(System.getProperty("partest.cwd")).getOrElse(".")) /** The base directory for this test, usually a subdirectory of "test/files/presentation/" */ val baseDir = Option(System.getProperty("partest.testname")).map(outDir / _).getOrElse(Path(".")) -// settings.YpresentationDebug.value = true - lazy val compiler = new Global(settings, reporter) + /** If there's a file ending in .opts, read it and parse it for cmd line arguments. */ + val argsString = { + val optsFile = outDir / "%s.opts".format(System.getProperty("partest.testname")) + val str = try File(optsFile).slurp() catch { + case e: java.io.IOException => "" + } + str.lines.filter(!_.startsWith("#")).mkString(" ") + } + + def prepareSettings() { + // need this so that the classpath comes from what partest + // instead of scala.home + settings.usejavacp.value = !argsString.contains("-bootclasspath") + + // pass any options coming from outside + settings.processArgumentString(argsString) match { + case (false, rest) => + println("error processing arguments (unprocessed: %s)".format(rest)) + case _ => () + } + } + + protected def printClassPath { + println("\toutDir: %s".format(outDir.path)) + println("\tbaseDir: %s".format(baseDir.path)) + println("\targsString: %s".format(argsString)) + println("\tbootClassPath: %s".format(settings.bootclasspath.value)) + println("\tverbose: %b".format(settings.verbose.value)) + } + + lazy val compiler = { + prepareSettings() + new Global(settings, reporter) + } def sources(filename: String*): Seq[SourceFile] = for (f <- filename) yield -- cgit v1.2.3