@@ -13,16 +13,15 @@ import scala.util.Properties.setProp
1313import scala .tools .nsc .util .ScalaClassLoader
1414import scala .tools .nsc .io .Path
1515import scala .collection .{ mutable , immutable }
16- import scala . actors . Actor ._
17- import scala .actors . TIMEOUT
16+ import java . util . concurrent ._
17+ import scala .collection . convert . decorateAll . _
1818
1919case class TestRunParams (val scalaCheckParentClassLoader : ScalaClassLoader )
2020
2121trait DirectRunner {
22-
2322 def fileManager : FileManager
2423
25- import PartestDefaults .numActors
24+ import PartestDefaults .numThreads
2625
2726 def denotesTestFile (arg : String ) = Path (arg).hasExtension(" scala" , " res" , " xml" )
2827 def denotesTestDir (arg : String ) = Path (arg).ifDirectory(_.files.nonEmpty) exists (x => x)
@@ -37,53 +36,34 @@ trait DirectRunner {
3736 false
3837 })
3938 }
40-
41- def setProperties () {
42- if (isPartestDebug)
43- scala.actors.Debug .level = 3
44-
45- if (PartestDefaults .poolSize.isEmpty) {
46- scala.actors.Debug .info(" actors.corePoolSize not defined" )
47- setProp(" actors.corePoolSize" , " 12" )
48- }
49- }
50-
51- def runTestsForFiles (_kindFiles : List [File ], kind : String ): immutable.Map [String , Int ] = {
52- val kindFiles = onlyValidTestPaths(_kindFiles)
53- val groupSize = (kindFiles.length / numActors) + 1
54-
39+ def runTestsForFiles (_kindFiles : List [File ], kind : String ): immutable.Map [String , TestState ] = {
5540 // @partest maintainer: we cannot create a fresh file manager here
5641 // since the FM must respect --buildpath and --classpath from the command line
5742 // for example, see how it's done in ReflectiveRunner
5843 // val consFM = new ConsoleFileManager
5944 // import consFM.{ latestCompFile, latestLibFile, latestPartestFile }
60- val latestCompFile = new File (fileManager.LATEST_COMP )
45+ val latestCompFile = new File (fileManager.LATEST_COMP )
6146 val latestReflectFile = new File (fileManager.LATEST_REFLECT )
62- val latestLibFile = new File (fileManager.LATEST_LIB )
47+ val latestLibFile = new File (fileManager.LATEST_LIB )
6348 val latestPartestFile = new File (fileManager.LATEST_PARTEST )
64- val latestActorsFile = new File (fileManager.LATEST_ACTORS )
65- val latestActMigFile = new File (fileManager.LATEST_ACTORS_MIGRATION )
66- val scalacheckURL = PathSettings .scalaCheck.toURL
49+ val latestActorsFile = new File (fileManager.LATEST_ACTORS )
50+ val latestActMigFile = new File (fileManager.LATEST_ACTORS_MIGRATION )
51+ val scalacheckURL = PathSettings .scalaCheck.toURL
6752 val scalaCheckParentClassLoader = ScalaClassLoader .fromURLs(
6853 scalacheckURL :: (List (latestCompFile, latestReflectFile, latestLibFile, latestActorsFile, latestActMigFile, latestPartestFile).map(_.toURI.toURL))
6954 )
70- Output .init()
7155
72- val workers = kindFiles.grouped(groupSize).toList map { toTest =>
73- val worker = new Worker (fileManager, TestRunParams (scalaCheckParentClassLoader))
74- worker.start()
75- worker ! RunTests (kind, toTest)
76- worker
77- }
56+ val kindFiles = onlyValidTestPaths(_kindFiles)
57+ val pool = Executors .newFixedThreadPool(numThreads)
58+ val manager = new RunnerManager (kind, fileManager, TestRunParams (scalaCheckParentClassLoader))
59+ val futures = kindFiles map (f => (f, pool submit callable(manager runTest f))) toMap
60+
61+ pool.shutdown()
62+ pool.awaitTermination(1 , TimeUnit .HOURS )
7863
79- workers map { w =>
80- receiveWithin(3600 * 1000 ) {
81- case Results (testResults) => testResults
82- case TIMEOUT =>
83- // add at least one failure
84- NestUI .verbose(" worker timed out; adding failed test" )
85- Map (" worker timed out; adding failed test" -> 2 )
86- }
87- } reduceLeft (_ ++ _)
64+ for ((file, future) <- futures) yield {
65+ val state = if (future.isCancelled) TestState .Timeout else future.get
66+ (file.getAbsolutePath, state)
67+ }
8868 }
8969}
0 commit comments