diff options
Diffstat (limited to 'src/partest')
4 files changed, 62 insertions, 5 deletions
diff --git a/src/partest/scala/tools/partest/DirectTest.scala b/src/partest/scala/tools/partest/DirectTest.scala index ff047daf9e..af2fc986fa 100644 --- a/src/partest/scala/tools/partest/DirectTest.scala +++ b/src/partest/scala/tools/partest/DirectTest.scala @@ -37,7 +37,7 @@ abstract class DirectTest extends App { } // new compiler def newCompiler(args: String*): Global = { - val settings = newSettings((CommandLineParser tokenize extraSettings) ++ args.toList) + val settings = newSettings((CommandLineParser tokenize ("-d \"" + testOutput.path + "\" " + extraSettings)) ++ args.toList) if (settings.Yrangepos.value) new Global(settings) with interactive.RangePositions else new Global(settings) } diff --git a/src/partest/scala/tools/partest/MemoryTest.scala b/src/partest/scala/tools/partest/MemoryTest.scala new file mode 100644 index 0000000000..58d25d2f01 --- /dev/null +++ b/src/partest/scala/tools/partest/MemoryTest.scala @@ -0,0 +1,38 @@ +package scala.tools.partest + +abstract class MemoryTest { + def maxDelta: Double + def calcsPerIter: Int + def calc(): Unit + + def main(args: Array[String]) { + val rt = Runtime.getRuntime() + def memUsage() = { + import java.lang.management._ + import scala.collection.JavaConverters._ + val pools = ManagementFactory.getMemoryPoolMXBeans.asScala + pools.map(_.getUsage.getUsed).sum / 1000000d + } + + val history = scala.collection.mutable.ListBuffer[Double]() + def stressTestIter() = { + var i = 0 + while (i < calcsPerIter) { calc(); i += 1 } + 1 to 5 foreach (_ => rt.gc()) + history += memUsage + } + + 1 to 5 foreach (_ => stressTestIter()) + val reference = memUsage() + 1 to 5 foreach (_ => stressTestIter()) + 1 to 5 foreach (_ => rt.gc()) + val result = memUsage() + history += result + + val delta = result - reference + if (delta > maxDelta) { + println("FAILED") + history foreach (mb => println(mb + " Mb")) + } + } +} diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala index a07705322d..a890a57f14 100644 --- a/src/partest/scala/tools/partest/nest/DirectRunner.scala +++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala @@ -37,6 +37,8 @@ trait DirectRunner { }) } def runTestsForFiles(_kindFiles: List[File], kind: String): immutable.Map[String, TestState] = { + System.setProperty("line.separator", "\n") + // @partest maintainer: we cannot create a fresh file manager here // since the FM must respect --buildpath and --classpath from the command line // for example, see how it's done in ReflectiveRunner diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index f817b1c1af..d4b9feecce 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -138,12 +138,29 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP catch exHandler(output, "javac command failed:\n" + args.map(" " + _ + "\n").mkString + "\n", CompilerCrashed) } - /** Runs command redirecting standard out and - * error out to output file. + /** Runs command redirecting standard out and error out to output file. + * Overloaded to accept a sequence of arguments. */ private def runCommand(args: Seq[String], outFile: File): Boolean = { NestUI.verbose("running command:\n"+args.map(" " + _ + "\n").mkString) - (Process(args) #> outFile !) == 0 + runCommandImpl(Process(args), outFile) + } + + /** Runs command redirecting standard out and error out to output file. + * Overloaded to accept a single string = concatenated command + arguments. + */ + private def runCommand(command: String, outFile: File): Boolean = { + NestUI.verbose("running command:"+command) + runCommandImpl(Process(command), outFile) + } + + private def runCommandImpl(process: => ProcessBuilder, outFile: File): Boolean = { + val exitCode = (process #> outFile !) + // normalize line endings + // System.getProperty("line.separator") should be "\n" here + // so reading a file and writing it back should convert all CRLFs to LFs + SFile(outFile).printlnAll(SFile(outFile).lines.toList: _*) + exitCode == 0 } @inline private def isJava(f: File) = SFile(f) hasExtension "java" @@ -791,7 +808,7 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP } else file.getAbsolutePath - val ok = ((cmdString+argString) #> logFile !) == 0 + val ok = runCommand(cmdString+argString, logFile) ( ok && diffCheck(file, compareOutput(file.getParentFile, logFile)) ) } catch { case e: Exception => NestUI.verbose("caught "+e) ; false } |