changeset 45757:1017cd5d6506

8183021: JShell tests: Fix failing tests on Windows Reviewed-by: jjg, rfield
author jlahoda
date Fri, 30 Jun 2017 20:03:07 +0200
parents 67f4f8f4d34a
children b2a0122861f5
files langtools/test/jdk/jshell/ToolBasicTest.java langtools/test/jdk/jshell/ToolMultilineSnippetHistoryTest.java langtools/test/jdk/jshell/UITesting.java
diffstat 3 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/test/jdk/jshell/ToolBasicTest.java	Fri Jun 30 05:47:35 2017 -0700
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java	Fri Jun 30 20:03:07 2017 +0200
@@ -325,12 +325,12 @@
         String tilde = "~" + File.separator;
         test(
                 (a) -> assertCommand(a, "/env --class-path " + tilde + "forblato",
-                        "|  File '" + System.getProperty("user.home") + File.separator
-                                + "forblato' for '--class-path' is not found."),
+                        "|  File '" + Paths.get(System.getProperty("user.home"), "forblato").toString()
+                                + "' for '--class-path' is not found."),
                 (a) -> assertCommand(a, "/env --class-path " + jarPath + File.pathSeparator
                                                             + tilde + "forblato",
-                        "|  File '" + System.getProperty("user.home") + File.separator
-                                + "forblato' for '--class-path' is not found.")
+                        "|  File '" + Paths.get(System.getProperty("user.home"), "forblato").toString()
+                                + "' for '--class-path' is not found.")
         );
     }
 
@@ -370,8 +370,8 @@
         String tilde = "~" + File.separatorChar;
         test(
                 (a) -> assertCommand(a, "/env --module-path " + tilde + "snardugol",
-                        "|  File '" + System.getProperty("user.home")
-                                + File.separatorChar + "snardugol' for '--module-path' is not found.")
+                        "|  File '" + Paths.get(System.getProperty("user.home"), "snardugol").toString()
+                                + "' for '--module-path' is not found.")
         );
     }
 
--- a/langtools/test/jdk/jshell/ToolMultilineSnippetHistoryTest.java	Fri Jun 30 05:47:35 2017 -0700
+++ b/langtools/test/jdk/jshell/ToolMultilineSnippetHistoryTest.java	Fri Jun 30 20:03:07 2017 +0200
@@ -38,6 +38,10 @@
 @Test
 public class ToolMultilineSnippetHistoryTest extends UITesting {
 
+    public ToolMultilineSnippetHistoryTest() {
+        super(true);
+    }
+
     public void testUpArrow() throws Exception {
         doRunTest((inputSink, out) -> {
             inputSink.write("int x=\n44\n");
--- a/langtools/test/jdk/jshell/UITesting.java	Fri Jun 30 05:47:35 2017 -0700
+++ b/langtools/test/jdk/jshell/UITesting.java	Fri Jun 30 20:03:07 2017 +0200
@@ -41,6 +41,16 @@
 
 public class UITesting {
 
+    private final boolean laxLineEndings;
+
+    public UITesting() {
+        this(false);
+    }
+
+    public UITesting(boolean laxLineEndings) {
+        this.laxLineEndings = laxLineEndings;
+    }
+
     protected void doRunTest(Test test) throws Exception {
         // turn on logging of launch failures
         Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
@@ -120,7 +130,7 @@
     }
 
     protected void waitOutput(StringBuilder out, String expected) {
-        expected = expected.replaceAll("\n", System.getProperty("line.separator"));
+        expected = expected.replaceAll("\n", laxLineEndings ? "\r?\n" : System.getProperty("line.separator"));
         Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL);
         synchronized (out) {
             long s = System.currentTimeMillis();