diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-22 10:42:07 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-22 10:42:07 -0700 |
commit | bfd847848e82b2fad7170043cf07b3691c722e65 (patch) | |
tree | a59dc9c69dcb067f00150970a0e44a35de66e67f | |
parent | 8a6a3b99a56f4ae53cbc7036615e8a78aa57d5e9 (diff) | |
parent | e6a5f19ff7ecaf90659070438c131cf316845c64 (diff) | |
download | scala-bfd847848e82b2fad7170043cf07b3691c722e65.tar.gz scala-bfd847848e82b2fad7170043cf07b3691c722e65.tar.bz2 scala-bfd847848e82b2fad7170043cf07b3691c722e65.zip |
Merge pull request #1377 from scalamacros/topic/partest-always-lf
partest now always produces log files with LFs
-rw-r--r-- | src/partest/scala/tools/partest/nest/DirectRunner.scala | 2 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/nest/RunnerManager.scala | 25 |
2 files changed, 23 insertions, 4 deletions
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 } |