changeset 395:e8c09609767c

7901926: Avoid \n for systems that have different line separator Contributed-by: Jerzy Krolak <j.krolak@gmail.com>
author shade
date Mon, 27 Mar 2017 18:35:03 +0200
parents adba8ecf2dba
children 1b0f8547b888
files jcstress-core/src/main/java/org/openjdk/jcstress/Main.java jcstress-core/src/main/java/org/openjdk/jcstress/Options.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/TextReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/util/OptionFormatter.java jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenerator.java
diffstat 7 files changed, 27 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/Main.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/Main.java	Mon Mar 27 18:35:03 2017 +0200
@@ -74,7 +74,7 @@
             stream = new URL(manifestPath).openStream();
             Manifest manifest = new Manifest(stream);
             Attributes attr = manifest.getMainAttributes();
-            out.printf("Rev: %s, built by %s with %s at %s\n",
+            out.printf("Rev: %s, built by %s with %s at %s%n",
                     attr.getValue("Implementation-Build"),
                     attr.getValue("Built-By"),
                     attr.getValue("Build-Jdk"),
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/Options.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/Options.java	Mon Mar 27 18:35:03 2017 +0200
@@ -273,12 +273,12 @@
 
     public void printSettingsOn(PrintStream out) {
         out.printf("  Hardware threads in use/available: %d/%d, %s%n", getUserCPUs(), getSystemCPUs(), getSpinStyle());
-        out.printf("  Test preset mode: \"%s\"\n", mode);
-        out.printf("  Writing the test results to \"%s\"\n", resultFile);
-        out.printf("  Parsing results to \"%s\"\n", resultDir);
-        out.printf("  Running each test matching \"%s\" for %d forks, %d iterations, %d ms each\n", getTestFilter(), getForks(), getIterations(), getTime());
-        out.printf("  Each JVM would execute at most %d tests in the row.\n", getBatchSize());
-        out.printf("  Solo stride size will be autobalanced within [%d, %d] elements, but taking no more than %d Mb.\n", getMinStride(), getMaxStride(), getMaxFootprintMb());
+        out.printf("  Test preset mode: \"%s\"%n", mode);
+        out.printf("  Writing the test results to \"%s\"%n", resultFile);
+        out.printf("  Parsing results to \"%s\"%n", resultDir);
+        out.printf("  Running each test matching \"%s\" for %d forks, %d iterations, %d ms each%n", getTestFilter(), getForks(), getIterations(), getTime());
+        out.printf("  Each JVM would execute at most %d tests in the row.%n", getBatchSize());
+        out.printf("  Solo stride size will be autobalanced within [%d, %d] elements, but taking no more than %d Mb.%n", getMinStride(), getMaxStride(), getMaxFootprintMb());
 
         out.println();
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Mon Mar 27 18:35:03 2017 +0200
@@ -123,7 +123,7 @@
     private void printLine(TestResult r) {
         String label = ReportUtils.statusToLabel(r);
         output.printf("\r%" + progressLen + "s\r", "");
-        output.printf("%10s %s\n", "[" + label + "]", StringUtils.chunkName(r.getName()));
+        output.printf("%10s %s%n", "[" + label + "]", StringUtils.chunkName(r.getName()));
     }
 
     private void printProgress() {
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java	Mon Mar 27 18:35:03 2017 +0200
@@ -56,10 +56,11 @@
 
         if (!failures.isEmpty()) {
             StringBuilder sb = new StringBuilder();
+            sb.append(System.lineSeparator());
             for (String f : failures) {
-                sb.append(f).append("\n");
+                sb.append(f).append(System.lineSeparator());
             }
-            throw new AssertionError("TEST FAILURES: \n" + sb.toString());
+            throw new AssertionError("TEST FAILURES: " + sb.toString());
         }
     }
 
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/TextReportPrinter.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/TextReportPrinter.java	Mon Mar 27 18:35:03 2017 +0200
@@ -121,7 +121,7 @@
 
     public void emitTest(TestResult result) {
         emittedTests.add(result);
-        pw.printf("%10s %s\n", "[" + ReportUtils.statusToLabel(result) + "]", StringUtils.chunkName(result.getName()));
+        pw.printf("%10s %s%n", "[" + ReportUtils.statusToLabel(result) + "]", StringUtils.chunkName(result.getName()));
         ReportUtils.printDetails(pw, result, false);
         ReportUtils.printMessages(pw, result);
     }
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/util/OptionFormatter.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/OptionFormatter.java	Mon Mar 27 18:35:03 2017 +0200
@@ -36,12 +36,16 @@
     public String format(Map<String, ? extends OptionDescriptor> options) {
         StringBuilder sb = new StringBuilder();
         sb.append("Usage: java -jar jcstress.jar [options]");
-        sb.append("\n");
-        sb.append(" [opt] means optional argument.\n");
-        sb.append(" <opt> means required argument.\n");
-        sb.append(" \"+\" means comma-separated list of values.\n");
-        sb.append(" \"time\" arguments accept time suffixes, like \"100ms\".\n");
-        sb.append("\n");
+        sb.append(System.lineSeparator());
+        sb.append(" [opt] means optional argument.");
+        sb.append(System.lineSeparator());
+        sb.append(" <opt> means required argument.");
+        sb.append(System.lineSeparator());
+        sb.append(" \"+\" means comma-separated list of values.");
+        sb.append(System.lineSeparator());
+        sb.append(" \"time\" arguments accept time suffixes, like \"100ms\".");
+        sb.append(System.lineSeparator());
+        sb.append(System.lineSeparator());
         for (OptionDescriptor each : options.values()) {
             if (each.options().contains("hostName")) continue;
             if (each.options().contains("hostPort")) continue;
@@ -53,7 +57,7 @@
 
     private Collection<String> rewrap(String lines) {
         Collection<String> result = new ArrayList<>();
-        String[] words = lines.split("[ \n]");
+        String[] words = lines.split("[ \n\r]");
         String line = "";
         int cols = 0;
         for (String w : words) {
@@ -102,7 +106,7 @@
             if (first) {
                 first = false;
             } else {
-                line.append("\n");
+                line.append(System.lineSeparator());
                 line.append(String.format("%-30s", ""));
             }
             if (!l.trim().isEmpty()) {
@@ -110,8 +114,8 @@
             }
         }
 
-        line.append(System.getProperty("line.separator"));
-        line.append(System.getProperty("line.separator"));
+        line.append(System.lineSeparator());
+        line.append(System.lineSeparator());
         return line.toString();
     }
 
--- a/jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenerator.java	Mon Mar 27 18:18:22 2017 +0200
+++ b/jcstress-result-gen/src/main/java/org/openjdk/jcstress/ResultGenerator.java	Mon Mar 27 18:35:03 2017 +0200
@@ -121,7 +121,7 @@
         pw.println("        if (this == o) return true;");
         pw.println("        if (o == null || getClass() != o.getClass()) return false;");
         pw.println();
-        pw.println("        " + name + " that = (" + name + ") o;\n");
+        pw.println("        " + name + " that = (" + name + ") o;");
 
         {
             int n = 1;