From e6a5f19ff7ecaf90659070438c131cf316845c64 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 22 Sep 2012 00:45:54 +0200 Subject: partest now always produces log files with LFs --- .../scala/tools/partest/nest/DirectRunner.scala | 2 ++ .../scala/tools/partest/nest/RunnerManager.scala | 25 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src') 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 4961424e1b..7a42853749 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" @@ -767,7 +784,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 } -- cgit v1.2.3