@@ -14,123 +14,93 @@ import scala.util.Properties.{ propOrElse, scalaCmd, scalacCmd }
14
14
import scala .tools .nsc .{ io , util }
15
15
import PathResolver .{ Environment , Defaults }
16
16
17
- case class ConsoleFileManager (
18
- testBuild : Option [String ] = PartestDefaults .testBuild,
19
- testClasses : Option [String ] = None ,
20
- updateCheck : Boolean = false ,
21
- failed : Boolean = false ) extends FileManager {
22
- def testBuildFile = testBuild map (testParent / _)
23
-
24
- lazy val srcDir = PathSettings .srcDir
25
- lazy val testRootDir = PathSettings .testRoot
26
- lazy val testRootPath = testRootDir.toAbsolute.path
27
- def testParent = testRootDir.parent
28
-
29
- override def compilerUnderTest =
30
- (if (testClasses.isDefined) testClassesDir
31
- else testBuildFile getOrElse {
32
- latestCompFile.getParentFile.getParentFile.getAbsoluteFile
33
- }).toString
34
-
35
-
36
- vlog(" COMPILATION_CLASSPATH: " + COMPILATION_CLASSPATH )
37
-
38
- if (! srcDir.isDirectory) {
39
- NestUI .failure(" Source directory \" " + srcDir.path + " \" not found" )
40
- sys.exit(1 )
41
- }
42
-
43
- lazy val COMPILATION_CLASSPATH = {
17
+ object ConsoleFileManager {
18
+ val classPath = {
19
+ val srcDir = {
20
+ val src = PathSettings .srcDir
21
+ if (! src.isDirectory) {
22
+ NestUI .failure(" Source directory \" " + src.path + " \" not found" )
23
+ sys.exit(1 )
24
+ }
25
+ src
26
+ }
44
27
val libs = (srcDir / Directory (" lib" )).files filter (_ hasExtension " jar" ) map (_.toCanonical.path)
45
28
46
29
// add all jars in libs
47
- (PartestDefaults .classPath :: libs.toList) mkString pathSeparator
30
+ val cp = (PartestDefaults .classPath ++ libs.toList)
31
+ vlog(" testClassPath: " + cp)
32
+ cp map (Path (_))
48
33
}
49
34
50
- def findLatest () {
35
+ def mostRecentTrifecta (testBuild : Option [String ], testClasses : Option [String ]) = {
36
+ val testParent = PathSettings .testRoot.parent
37
+ val testClassesDir = testClasses map (tc => Path (tc).toCanonical.toDirectory)
38
+ val testBuildDir = testBuild map (b => (testParent / b).toCanonical.toDirectory)
39
+
51
40
vlog(" test parent: " + testParent)
52
41
53
42
def prefixFileWith (parent : File , relPath : String ) = (SFile (parent) / relPath).toCanonical
54
43
def prefixFile (relPath : String ) = (testParent / relPath).toCanonical
55
44
56
- if (testClasses.isDefined) {
57
- testClassesDir = Path (testClasses.get).toCanonical.toDirectory
58
- vlog(" Running with classes in " + testClassesDir)
59
-
60
- latestLibFile = testClassesDir / " library"
61
- latestReflectFile = testClassesDir / " reflect"
62
- latestCompFile = testClassesDir / " compiler"
63
- }
64
- else if (testBuild.isDefined) {
65
- val dir = Path (testBuild.get)
66
- vlog(" Running on " + dir)
67
- latestLibFile = dir / " lib/scala-library.jar"
68
- latestReflectFile = dir / " lib/scala-reflect.jar"
69
- latestCompFile = dir / " lib/scala-compiler.jar"
70
- }
71
- else {
72
- def setupQuick () {
45
+ (testClassesDir map { testClassesDir => vlog(s " Running with classes in $testClassesDir" )
46
+ (testClassesDir / " library" ,
47
+ testClassesDir / " reflect" ,
48
+ testClassesDir / " compiler" )
49
+ }) orElse (testBuildDir map { testBuild => vlog(s " Running on $testBuild" )
50
+ (testBuild / " lib/scala-library.jar" ,
51
+ testBuild / " lib/scala-reflect.jar" ,
52
+ testBuild / " lib/scala-compiler.jar" )
53
+ }) getOrElse {
54
+ def setupQuick = {
73
55
vlog(" Running build/quick" )
74
- latestLibFile = prefixFile(" build/quick/classes/library" )
75
- latestReflectFile = prefixFile(" build/quick/classes/reflect" )
76
- latestCompFile = prefixFile(" build/quick/classes/compiler" )
56
+ ( prefixFile(" build/quick/classes/library" ),
57
+ prefixFile(" build/quick/classes/reflect" ),
58
+ prefixFile(" build/quick/classes/compiler" ) )
77
59
}
78
60
79
- def setupInst () {
61
+ def setupInst = {
80
62
vlog(" Running dist (installed)" )
81
63
val p = testParent.getParentFile
82
- latestLibFile = prefixFileWith(p, " lib/scala-library.jar" )
83
- latestReflectFile = prefixFileWith(p, " lib/scala-reflect.jar" )
84
- latestCompFile = prefixFileWith(p, " lib/scala-compiler.jar" )
64
+ ( prefixFileWith(p, " lib/scala-library.jar" ),
65
+ prefixFileWith(p, " lib/scala-reflect.jar" ),
66
+ prefixFileWith(p, " lib/scala-compiler.jar" ) )
85
67
}
86
68
87
- def setupDist () {
69
+ def setupDist = {
88
70
vlog(" Running dists/latest" )
89
- latestLibFile = prefixFile(" dists/latest/lib/scala-library.jar" )
90
- latestReflectFile = prefixFile(" dists/latest/lib/scala-reflect.jar" )
91
- latestCompFile = prefixFile(" dists/latest/lib/scala-compiler.jar" )
71
+ ( prefixFile(" dists/latest/lib/scala-library.jar" ),
72
+ prefixFile(" dists/latest/lib/scala-reflect.jar" ),
73
+ prefixFile(" dists/latest/lib/scala-compiler.jar" ) )
92
74
}
93
75
94
- def setupPack () {
76
+ def setupPack = {
95
77
vlog(" Running build/pack" )
96
- latestLibFile = prefixFile(" build/pack/lib/scala-library.jar" )
97
- latestReflectFile = prefixFile(" build/pack/lib/scala-reflect.jar" )
98
- latestCompFile = prefixFile(" build/pack/lib/scala-compiler.jar" )
78
+ ( prefixFile(" build/pack/lib/scala-library.jar" ),
79
+ prefixFile(" build/pack/lib/scala-reflect.jar" ),
80
+ prefixFile(" build/pack/lib/scala-compiler.jar" ) )
99
81
}
100
82
101
83
def mostRecentOf (base : String , names : String * ) =
102
84
names map (x => prefixFile(base + " /" + x).lastModified) reduceLeft (_ max _)
103
85
104
86
// detect most recent build
105
87
val quickTime = mostRecentOf(" build/quick/classes" , " compiler/compiler.properties" , " reflect/reflect.properties" , " library/library.properties" )
106
- val packTime = mostRecentOf(" build/pack/lib" , " scala-compiler.jar" , " scala-reflect.jar" , " scala-library.jar" )
107
- val distTime = mostRecentOf(" dists/latest/lib" , " scala-compiler.jar" , " scala-reflect.jar" , " scala-library.jar" )
108
88
val instTime = mostRecentOf(" lib" , " scala-compiler.jar" , " scala-reflect.jar" , " scala-library.jar" )
89
+ val distTime = mostRecentOf(" dists/latest/lib" , " scala-compiler.jar" , " scala-reflect.jar" , " scala-library.jar" )
90
+ val packTime = mostRecentOf(" build/pack/lib" , " scala-compiler.jar" , " scala-reflect.jar" , " scala-library.jar" )
109
91
110
92
val pairs = Map (
111
- (quickTime, () => setupQuick() ),
112
- (packTime , () => setupPack() ),
113
- (distTime, () => setupDist() ),
114
- (instTime , () => setupInst() )
93
+ (quickTime, () => setupQuick),
94
+ (instTime , () => setupInst ),
95
+ (distTime, () => setupDist),
96
+ (packTime , () => setupPack )
115
97
)
116
98
117
99
// run setup based on most recent time
118
100
pairs(pairs.keys max)()
119
101
}
120
-
121
- LATEST_LIB = latestLibFile.getAbsolutePath
122
- LATEST_REFLECT = latestReflectFile.getAbsolutePath
123
- LATEST_COMP = latestCompFile.getAbsolutePath
124
102
}
125
-
126
- var LATEST_LIB : String = " "
127
- var LATEST_REFLECT : String = " "
128
- var LATEST_COMP : String = " "
129
-
130
- var latestLibFile : File = _
131
- var latestReflectFile : File = _
132
- var latestCompFile : File = _
133
- var testClassesDir : Directory = _
134
- // initialize above fields
135
- findLatest()
136
103
}
104
+
105
+ case class ConsoleFileManager (testBuild : Option [String ] = PartestDefaults .testBuild, testClasses : Option [String ] = None )
106
+ extends FileManager (ConsoleFileManager .classPath, ConsoleFileManager .mostRecentTrifecta(testBuild, testClasses))
0 commit comments