Skip to content

Fix for test 'repl\i5218' on Windows #5814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/printing/Texts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object Texts {
case _ =>
var follow = false
for (elem <- relems.reverse) {
if (follow) sb.append("\n")
if (follow) sb.append(System.lineSeparator)
elem.print(sb, numberWidth)
follow = true
}
Expand Down
16 changes: 12 additions & 4 deletions compiler/test/dotty/tools/repl/ScriptedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ class ScriptedTests extends ReplTest with MessageRendering {
case nonEmptyLine => nonEmptyLine :: Nil
}

def printOutput(prefix: String, output: String): Unit = {
val bytes = output.getBytes
println(prefix+
" (#chars="+output.length+
", #CR="+(bytes.count(_ == 13))+
", #LF="+(bytes.count(_ == 10))+
") ========>"+EOL+
output.replaceAll("\r", "<CR>").replaceAll("\n", "<LF>"+EOL))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not have these replacements done in the printed output, it makes it harder to fix a broken test by copy-pasting the console output in a file.

}

val expectedOutput =
Source.fromFile(f, "UTF-8").getLines().flatMap(filterEmpties).mkString(EOL)
val actualOutput = {
Expand All @@ -79,10 +89,8 @@ class ScriptedTests extends ReplTest with MessageRendering {
}

if (expectedOutput != actualOutput) {
println("expected =========>")
println(expectedOutput)
println("actual ===========>")
println(actualOutput)
printOutput("expected", expectedOutput)
printOutput("actual", actualOutput)

fail(s"Error in file $f, expected output did not match actual")
}
Expand Down
5 changes: 2 additions & 3 deletions compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tools
package vulpix

import java.io.{ File => JFile, InputStreamReader, BufferedReader, PrintStream }
import java.nio.file.Paths;
import java.nio.file.Paths
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.TimeoutException

Expand Down Expand Up @@ -156,10 +156,9 @@ trait RunnerOrchestration {
* scala library.
*/
private def createProcess: Process = {
val sep = JFile.separator
val url = classOf[ChildJVMMain].getProtectionDomain.getCodeSource.getLocation
val cp = Paths.get(url.toURI).toString + JFile.pathSeparator + Properties.scalaLibrary
val javaBin = sys.props("java.home") + sep + "bin" + sep + "java"
val javaBin = Paths.get(sys.props("java.home"), "bin", "java").toString
new ProcessBuilder(javaBin, "-Dfile.encoding=UTF-8", "-Xmx1g", "-cp", cp, "dotty.tools.vulpix.ChildJVMMain")
.redirectErrorStream(true)
.redirectInput(ProcessBuilder.Redirect.PIPE)
Expand Down