You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
are failing on Windows due to EOL mismatches between the expected output and the actual output produced by a REPL snipplet. Concretely statement assertEquals(expected, actual) does fail in 4 cases : line 58, line 60, line 160 and line 176.
Compilation output
> sbt -sbt-version 1.3.8 "compile; test"
[info] Loading settings for project dotty-multiline-build-build from build.sbt ...
[info] Loading project definition from W:\dotty-multiline\project\project
[...]
[error] Failed: Total 364, Failed 10, Errors 0, Passed 352, Skipped 2
[error] Failed tests:
[error] dotty.tools.repl.ReplCompilerTests <=======
[error] dotty.tools.repl.LoadTests <=======
[error] dotty.tools.dotc.CompilationTests
[error] dotty.tools.repl.ScriptedTests
[info] Passed: Total 75, Failed 0, Errors 0, Passed 75
[error] (dotty-compiler / Test / testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 1421 s (23:41), completed 20 Feb 2020 23:16:27
Expectation
> sbt -sbt-version 1.3.8 "compile; test"
[info] Loading settings for project dotty-multiline-build-build from build.sbt ...
[info] Loading project definition from W:\dotty-multiline\project\project
[...]
[error] Failed: Total 363, Failed 5, Errors 0, Passed 356, Skipped 2
[error] Failed tests:
[error] dotty.tools.dotc.CompilationTests
[error] dotty.tools.repl.ScriptedTests
[error] (dotty-compiler / Test / testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 1421 s (23:41), completed 20 Feb 2020 22:48:17
NB. Both tests dotc.CompilationTests and repl.ScriptedTests will be handled by another PR.
Solution
As a preamble, I'd like to mention that file repl.ReplCompilerTests.scala uses in some test cases a workaround to that issue, namely function lines() - which returns a list of lines (w/o line ending) - is used in two assertEquals tests (line 57 and line 128) where two lists rather than two (multiline) strings are compared.
My solution is to replaced assertEquals with assertMultilineEquals in the above 4 cases.
Before submitting a PR, I'd like to get your feedback about the following two implementations :
Solution 1
String expected keeps untouched (role similar to a check file).
objectLoadTests {
// ... (some more code) ...privatevalpattern=Pattern.compile("\\r[\\n]?|\\n");
// Ensure 'expected' and 'actual' contain the same line separator(s).privatedefassertMultiLineEquals(expected: String, actual: String):Unit= {
valm= pattern.matcher(expected)
valactual0=if (m.find()) {
valexpectedLineSep= m.group()
pattern.matcher(actual).replaceAll(expectedLineSep)
}
else
actual
assertEquals(expected, actual0)
}
}
Solution 2
Both strings are transformed ("brut force") and passed to assertEquals.
objectLoadTests {
// ... (some more code) ...privatevalpattern=Pattern.compile("\\r[\\n]?|\\n");
// Ensure 'expected' and 'actual' contain the same line separator(s).privatedefassertMultiLineEquals(expected: String, actual: String):Unit= {
valexpected0= pattern.matcher(expected).replaceAll(System.lineSeparator)
valactual0= pattern.matcher(actual).replaceAll(System.lineSeparator)
assertEquals(expected0, actual0)
}
}
The text was updated successfully, but these errors were encountered:
Minimized code
The following two REPL tests
LoadTests.scala
ReplCompilerTests.scala
are failing on Windows due to EOL mismatches between the expected output and the actual output produced by a REPL snipplet. Concretely statement
assertEquals(expected, actual)
does fail in 4 cases : line 58, line 60, line 160 and line 176.Compilation output
Expectation
NB. Both tests
dotc.CompilationTests
andrepl.ScriptedTests
will be handled by another PR.Solution
As a preamble, I'd like to mention that file
repl.ReplCompilerTests.scala
uses in some test cases a workaround to that issue, namely functionlines()
- which returns a list of lines (w/o line ending) - is used in twoassertEquals
tests (line 57 and line 128) where two lists rather than two (multiline) strings are compared.My solution is to replaced
assertEquals
withassertMultilineEquals
in the above 4 cases.Before submitting a PR, I'd like to get your feedback about the following two implementations :
Solution 1
String
expected
keeps untouched (role similar to a check file).Solution 2
Both strings are transformed ("brut force") and passed to
assertEquals
.The text was updated successfully, but these errors were encountered: