Skip to content
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

Tests fail on windows because of line separator #102

Open
22222 opened this issue Sep 27, 2015 · 0 comments
Open

Tests fail on windows because of line separator #102

22222 opened this issue Sep 27, 2015 · 0 comments

Comments

@22222
Copy link

22222 commented Sep 27, 2015

The expected values for all of the tests use just line feeds ("\n") for line separators. But the line separators are added by the PrintStream class, and on Windows it will use a carriage return and line feed ("\r\n") as the line separator by default. This makes all tests with at least one line of expected output fail.

A solution I've been using is to explicitly set the system line.separator property to "\n" before creating the new PrintStream for the output:

diff --git a/src/test/scala/org/arnoldc/ByteCodeExecutor.scala b/src/test/scala/org/arnoldc/ByteCodeExecutor.scala
index ef9aebf..d6dc5f2 100644
--- a/src/test/scala/org/arnoldc/ByteCodeExecutor.scala
+++ b/src/test/scala/org/arnoldc/ByteCodeExecutor.scala
@@ -9,6 +9,7 @@ class ByteCodeExecutor extends ClassLoader {

     val outputRedirectionStream = new ByteArrayOutputStream()

+   System.setProperty("line.separator", "\n");
    System.setOut(new PrintStream(outputRedirectionStream))

     invokeMainMethod(bytecode, className)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant