blob: 36671555d11a73f7d7ed072babf1a58812aadd55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package scala.tools.nsc
package interactive
package tests
import java.io.File.pathSeparatorChar
import java.io.File.separatorChar
import scala.tools.nsc.interactive.tests.core.PresentationCompilerInstance
import scala.tools.nsc.io.File
import core.Reporter
import core.TestSettings
trait InteractiveTestSettings extends TestSettings with PresentationCompilerInstance {
/** Character delimiter for comments in .opts file */
private final val CommentStartDelimiter = "#"
private final val TestOptionsFileExtension = "flags"
/** Prepare the settings object. Load the .opts file and adjust all paths from the
* Unix-like syntax to the platform specific syntax. This is necessary so that a
* single .opts file can be used on all platforms.
*
* @note Bootclasspath is treated specially. If there is a -bootclasspath option in
* the file, the 'usejavacp' setting is set to false. This ensures that the
* bootclasspath takes precedence over the scala-library used to run the current
* test.
*/
override protected def prepareSettings(settings: Settings) {
import java.io.File._
def adjustPaths(paths: settings.PathSetting*) {
for (p <- paths if argsString.contains(p.name)) p.value = p.value.map {
case '/' => separatorChar
case ':' => pathSeparatorChar
case c => c
}
}
// 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 _ => ()
}
adjustPaths(settings.bootclasspath, settings.classpath, settings.javabootclasspath, settings.sourcepath)
}
/** If there's a file ending in .opts, read it and parse it for cmd line arguments. */
protected val argsString = {
val optsFile = outDir / "%s.%s".format(System.getProperty("partest.testname"), TestOptionsFileExtension)
val str = try File(optsFile).slurp() catch {
case e: java.io.IOException => ""
}
str.lines.filter(!_.startsWith(CommentStartDelimiter)).mkString(" ")
}
override protected def printClassPath(implicit reporter: Reporter) {
reporter.println("\toutDir: %s".format(outDir.path))
reporter.println("\tbaseDir: %s".format(baseDir.path))
reporter.println("\targsString: %s".format(argsString))
super.printClassPath(reporter)
}
}
|