diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-03-29 17:14:40 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-03-29 18:06:13 +0200 |
commit | 6d852e1f30ef9e704dbd88aefae60ad632ad3541 (patch) | |
tree | a799ef7e00f1d4bc8eb9d22f2af11fec0f72ff1e /compiler/test | |
parent | f49c10d1667de897b2073d9b15c7c6cb8cc52482 (diff) | |
download | dotty-6d852e1f30ef9e704dbd88aefae60ad632ad3541.tar.gz dotty-6d852e1f30ef9e704dbd88aefae60ad632ad3541.tar.bz2 dotty-6d852e1f30ef9e704dbd88aefae60ad632ad3541.zip |
Fix #2147: redirect both java and scala std out/err
Diffstat (limited to 'compiler/test')
-rw-r--r-- | compiler/test/dotty/tools/dotc/ParallelTestTests.scala | 3 | ||||
-rw-r--r-- | compiler/test/dotty/tools/dotc/ParallelTesting.scala | 23 |
2 files changed, 22 insertions, 4 deletions
diff --git a/compiler/test/dotty/tools/dotc/ParallelTestTests.scala b/compiler/test/dotty/tools/dotc/ParallelTestTests.scala index 9964be036..cfb108ea7 100644 --- a/compiler/test/dotty/tools/dotc/ParallelTestTests.scala +++ b/compiler/test/dotty/tools/dotc/ParallelTestTests.scala @@ -52,4 +52,7 @@ class ParallelTestTests extends ParallelTesting { @Test def runStackOverflow: Unit = compileFile("../tests/partest-test/stackOverflow.scala", defaultOptions).expectFailure.checkRuns() + + @Test def runOutRedirects: Unit = + compileFile("../tests/partest-test/i2147.scala", defaultOptions).expectFailure.checkRuns() } diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala index 30679de9e..06105b043 100644 --- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala +++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala @@ -28,7 +28,7 @@ import dotc.util.DiffUtil * using this, you should be running your JUnit tests **sequentially**, as the * test suite itself runs with a high level of concurrency. */ -trait ParallelTesting { +trait ParallelTesting { self => import ParallelTesting._ import ParallelSummaryReport._ @@ -399,18 +399,33 @@ trait ParallelTesting { .takeWhile(_.getMethodName != "invoke0") .mkString(" ", "\n ", "") - import java.io.ByteArrayOutputStream + import java.io.{ ByteArrayOutputStream, PrintStream } import java.net.{ URL, URLClassLoader } val printStream = new ByteArrayOutputStream + val oldOut = System.out + val oldErr = System.out + try { // Do classloading magic and running here: val ucl = new URLClassLoader(Array(dir.toURI.toURL)) val cls = ucl.loadClass("Test") val meth = cls.getMethod("main", classOf[Array[String]]) - Console.withOut(printStream) { - meth.invoke(null, Array("jvm")) // partest passes at least "jvm" as an arg + self.synchronized { + try { + val ps = new PrintStream(printStream) + System.setOut(ps) + System.setErr(ps) + Console.withOut(printStream) { + Console.withErr(printStream) { + meth.invoke(null, Array("jvm")) // partest passes at least "jvm" as an arg + } + } + } finally { + System.setOut(oldOut) + System.setErr(oldErr) + } } } catch { |