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