@@ -21,6 +21,7 @@ import scala.reflect.io.AbstractFile
21
21
import scala .tools .nsc .reporters .{ConsoleReporter , Reporter }
22
22
import scala .tools .nsc .{CompilerCommand , Global , Settings }
23
23
import scala .util .chaining ._
24
+ import scala .sys .process ._
24
25
25
26
object ExtConsoleReporter {
26
27
def apply (settings : Settings , writer : PrintWriter ) = new ConsoleReporter (settings, Console .in, writer, writer).tap(_.shortname = true )
@@ -116,7 +117,7 @@ class DirectCompiler(val runner: Runner) {
116
117
if (command.files.nonEmpty) reportError(command.files.mkString(" flags file may only contain compiler options, found: " , space, " " ))
117
118
}
118
119
119
- suiteRunner.verbose(s " % scalac ${ sources.map(_.testIdent).mkString(space) }${ if (suiteRunner.debug) " -d " + outDir else " " }" )
120
+ suiteRunner.verbose(s " % compiling ${ sources.map(_.testIdent).mkString(space) }${ if (suiteRunner.debug) " -d " + outDir else " " }" )
120
121
121
122
def execCompile () =
122
123
if (command.shouldStopWithInfo) {
@@ -134,7 +135,21 @@ class DirectCompiler(val runner: Runner) {
134
135
result
135
136
}
136
137
137
- try { execCompile() }
138
+ def execOtherCompiler () = {
139
+ val stdout = new StringBuilder
140
+ val stderr = new StringBuilder
141
+ val logger = ProcessLogger (stdout append _, stderr append _)
142
+ val resultCode = (suiteRunner.config.optCompilerPath.get + " " + sources.map(_.getPath).mkString(" " )) ! logger
143
+ logWriter append stdout
144
+ logWriter append stderr
145
+ if (resultCode == 0 ) runner.genPass()
146
+ else runner.genFail(s " compilation failed " )
147
+ }
148
+
149
+ try {
150
+ if (suiteRunner.config.optCompilerPath.isEmpty) execCompile()
151
+ else execOtherCompiler()
152
+ }
138
153
catch { case t : Throwable => reportError(t.getMessage) ; runner.genCrash(t) }
139
154
finally { logWriter.close() }
140
155
}
0 commit comments