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

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

merged 3 commits into from
Jan 29, 2019

Conversation

michelou
Copy link
Contributor

@michelou michelou commented Jan 29, 2019

Output prior to change is:

[info] Test run started
[info] Test dotty.tools.repl.ScriptedTests.replTests started
expected =========>
scala> val tuple = (1, "2", 3L)
val tuple: (Int, String, Long) = (1,2,3)
scala> 0.0 *: tuple
val res0: Double *: (Int, String, Long)(tuple) = (0.0,1,2,3)
scala> tuple ++ tuple
val res1: Int *: String *: Long *:
  scala.Tuple.Concat[Unit, (Int, String, Long)(tuple)] = (1,2,3,1,2,3)
actual ===========>
scala> val tuple = (1, "2", 3L)
val tuple: (Int, String, Long) = (1,2,3)
scala> 0.0 *: tuple
val res0: Double *: (Int, String, Long)(tuple) = (0.0,1,2,3)
scala> tuple ++ tuple
val res1: Int *: String *: Long *:
  scala.Tuple.Concat[Unit, (Int, String, Long)(tuple)] = (1,2,3,1,2,3)
[error] Test dotty.tools.repl.ScriptedTests.replTests failed: java.lang.AssertionError: Error in file W:\dotty-replTests\compiler\target\scala-2.12\test-classes\repl\i5218, expected output did not match actual, took 2.024 sec
[error]     at dotty.tools.repl.ScriptedTests.testFile(ScriptedTests.scala:87)
[error]     at dotty.tools.repl.ScriptedTests.$anonfun$replTests$1(ScriptedTests.scala:91)
[error]     at dotty.tools.repl.ScriptedTests.$anonfun$replTests$1$adapted(ScriptedTests.scala:91)
[error]     at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
[error]     at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
[error]     at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
[error]     at dotty.tools.repl.ScriptedTests.replTests(ScriptedTests.scala:91)
[error]     ...
[info] Test dotty.tools.repl.ScriptedTests.typePrinterTests started
[info] Test run finished: 1 failed, 0 ignored, 2 total, 3.158s

With the addition of method printOutput in file test\dotty\tools\repl\ScriptedTests.scala we can see the issue with repl\i5218 on Windows (missing carriage return character on the second-last line):

[info] Test run started
[info] Test dotty.tools.repl.ScriptedTests.replTests started
expected (#chars=287, #CR=6, #LF=6) ========>
scala> val tuple = (1, "2", 3L)<CR><LF>
val tuple: (Int, String, Long) = (1,2,3)<CR><LF>
scala> 0.0 *: tuple<CR><LF>
val res0: Double *: (Int, String, Long)(tuple) = (0.0,1,2,3)<CR><LF>
scala> tuple ++ tuple<CR><LF>
val res1: Int *: String *: Long *:<CR><LF>
  scala.Tuple.Concat[Unit, (Int, String, Long)(tuple)] = (1,2,3,1,2,3)
actual (#chars=286, #CR=5, #LF=6) ========>
scala> val tuple = (1, "2", 3L)<CR><LF>
val tuple: (Int, String, Long) = (1,2,3)<CR><LF>
scala> 0.0 *: tuple<CR><LF>
val res0: Double *: (Int, String, Long)(tuple) = (0.0,1,2,3)<CR><LF>
scala> tuple ++ tuple<CR><LF>
val res1: Int *: String *: Long *:<LF>
  scala.Tuple.Concat[Unit, (Int, String, Long)(tuple)] = (1,2,3,1,2,3)
[error] Test dotty.tools.repl.ScriptedTests.replTests failed: java.lang.AssertionError: Error in file W:\dotty-replTests\compiler\target\scala-2.12\test-classes\repl\i5218, expected output did not match actual, took 2.1 sec
[error]     at dotty.tools.repl.ScriptedTests.testFile(ScriptedTests.scala:94)
[error]     at dotty.tools.repl.ScriptedTests.$anonfun$replTests$1(ScriptedTests.scala:98)
[error]     at dotty.tools.repl.ScriptedTests.$anonfun$replTests$1$adapted(ScriptedTests.scala:98)
[error]     at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
[error]     at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
[error]     at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
[error]     at dotty.tools.repl.ScriptedTests.replTests(ScriptedTests.scala:98)
[error]     ...
[info] Test dotty.tools.repl.ScriptedTests.typePrinterTests started
[info] Test run finished: 1 failed, 0 ignored, 2 total, 3.305s

In summary :

  • The fix is located in file src\dotty\tools\dotc\printing\Texts.scala
  • Method printOutput in file test\dotty\tools\repl\ScriptedTests.scala allows us to detect the issue with repl\i5218
  • Change in file test\dotty\tools\vulpix\RunnerOrchestration.scala is a small code improvement (not related to the issue).

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

", #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.

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @michelou

@allanrenucci allanrenucci merged commit 923fb06 into scala:master Jan 29, 2019
@michelou michelou deleted the dotty-replTests branch January 30, 2019 09:12
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

Successfully merging this pull request may close these issues.

4 participants