@@ -23,8 +23,6 @@ import dotc.interfaces.Diagnostic.ERROR
23
23
import dotc .util .DiffUtil
24
24
import dotc .{ Driver , Compiler }
25
25
26
- import vulpix .Statuses ._
27
-
28
26
/** A parallel testing suite whose goal is to integrate nicely with JUnit
29
27
*
30
28
* This trait can be mixed in to offer parallel testing to compile runs. When
@@ -54,6 +52,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
54
52
def outDir : JFile
55
53
def flags : Array [String ]
56
54
55
+ def classPath : String = {
56
+ val (beforeCp, cpAndAfter) = flags.toList.span(_ != " -classpath" )
57
+ if (cpAndAfter.nonEmpty) {
58
+ val (_ :: cpArg :: _) = cpAndAfter
59
+ s " ${outDir.getAbsolutePath}: " + cpArg
60
+ }
61
+ else outDir.getAbsolutePath
62
+ }
63
+
57
64
58
65
def title : String = self match {
59
66
case self : JointCompilationSource =>
@@ -294,15 +301,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
294
301
295
302
val files : Array [JFile ] = files0.flatMap(flattenFiles)
296
303
297
- def findJarFromRuntime (partialName : String ) = {
298
- val urls = ClassLoader .getSystemClassLoader.asInstanceOf [java.net.URLClassLoader ].getURLs.map(_.getFile.toString)
299
- urls.find(_.contains(partialName)).getOrElse {
300
- throw new java.io.FileNotFoundException (
301
- s """ Unable to locate $partialName on classpath:\n ${urls.toList.mkString(" \n " )}"""
302
- )
303
- }
304
- }
305
-
306
304
def addOutDir (xs : Array [String ]): Array [String ] = {
307
305
val (beforeCp, cpAndAfter) = xs.toList.span(_ != " -classpath" )
308
306
if (cpAndAfter.nonEmpty) {
@@ -313,11 +311,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
313
311
}
314
312
315
313
def compileWithJavac (fs : Array [String ]) = if (fs.nonEmpty) {
316
- val scalaLib = findJarFromRuntime(" scala-library-2." )
317
314
val fullArgs = Array (
318
315
" javac" ,
319
316
" -classpath" ,
320
- s " .: $scalaLib : ${targetDir.getAbsolutePath}"
317
+ s " .: ${ Jars .scalaLibraryFromRuntime} : ${targetDir.getAbsolutePath}"
321
318
) ++ flags.takeRight(2 ) ++ fs
322
319
323
320
Runtime .getRuntime.exec(fullArgs).waitFor() == 0
@@ -430,9 +427,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
430
427
private final class RunTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )
431
428
extends Test (testSources, times, threadLimit, suppressAllOutput) {
432
429
private def verifyOutput (checkFile : JFile , dir : JFile , testSource : TestSource , warnings : Int ) = {
433
- runMain(dir ) match {
434
- case success : Success => {
435
- val outputLines = success. output.lines.toArray
430
+ runMain(testSource.classPath ) match {
431
+ case Success (output) => {
432
+ val outputLines = output.lines.toArray
436
433
val checkLines : Array [String ] = Source .fromFile(checkFile).getLines.toArray
437
434
val sourceTitle = testSource.title
438
435
@@ -463,19 +460,16 @@ trait ParallelTesting extends RunnerOrchestration { self =>
463
460
}
464
461
}
465
462
466
- case failure : Failure =>
467
- echo(renderFailure(failure) )
463
+ case Failure (output) =>
464
+ echo(output )
468
465
failTestSource(testSource)
469
466
470
- case _ : Timeout =>
467
+ case Timeout =>
471
468
echo(" failed because test " + testSource.title + " timed out" )
472
469
failTestSource(testSource, Some (" test timed out" ))
473
470
}
474
471
}
475
472
476
- private def renderFailure (failure : Failure ): String =
477
- failure.message + " \n " + failure.stacktrace
478
-
479
473
protected def compilationRunnable (testSource : TestSource ): Runnable = new Runnable {
480
474
def run (): Unit = tryCompile(testSource) {
481
475
val (errorCount, warningCount, hasCheckFile, verifier : Function0 [Unit ]) = testSource match {
@@ -519,17 +513,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
519
513
}
520
514
521
515
if (errorCount == 0 && hasCheckFile) verifier()
522
- else if (errorCount == 0 ) runMain(testSource.outDir ) match {
523
- case status : Failure =>
524
- echo(renderFailure(status))
516
+ else if (errorCount == 0 ) runMain(testSource.classPath ) match {
517
+ case Success (_) => // success!
518
+ case Failure (output) =>
525
519
failTestSource(testSource)
526
- case _ : Timeout =>
527
- echo(" failed because test " + testSource.title + " timed out" )
520
+ case Timeout =>
528
521
failTestSource(testSource, Some (" test timed out" ))
529
- case _ : Success => // success!
530
522
}
531
523
else if (errorCount > 0 ) {
532
- echo(s " \n Compilation failed for: ' $testSource' " )
533
524
val buildInstr = testSource.buildInstructions(errorCount, warningCount)
534
525
addFailureInstruction(buildInstr)
535
526
failTestSource(testSource)
0 commit comments