< prev index next >

test/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java

Print this page
rev 11302 : 8156469: [JITtester] Difference in generated golden output when run with Jigsaw build
Reviewed-by:

*** 54,81 **** } Pattern splitOut = Pattern.compile("\\n"); // tests use \n only in stdout Pattern splitErr = Pattern.compile("\\r?\\n"); // can handle both \r\n and \n Path testDir = Paths.get(Utils.TEST_SRC); ! String goldOut = formatOutput(streamGoldFile(testDir, args[0], "out"), s -> true); ! String anlzOut = formatOutput(Arrays.stream(splitOut.split(oa.getStdout())), s -> true); Asserts.assertEQ(anlzOut, goldOut, "Actual stdout isn't equal to golden one"); ! // TODO: add a comment why we skip such lines ! Predicate<String> notStartWhitespaces = s -> !(s.startsWith("\t") || s.startsWith(" ")); ! String goldErr = formatOutput(streamGoldFile(testDir, args[0], "err"), notStartWhitespaces); ! String anlzErr = formatOutput(Arrays.stream(splitErr.split(oa.getStderr())), ! notStartWhitespaces); Asserts.assertEQ(anlzErr, goldErr, "Actual stderr isn't equal to golden one"); int exitValue = Integer.parseInt(streamGoldFile(testDir, args[0], "exit").findFirst().get()); oa.shouldHaveExitValue(exitValue); } ! private static String formatOutput(Stream<String> stream, Predicate<String> predicate) { ! String result = stream ! .filter(predicate) ! .collect(Collectors.joining(Utils.NEW_LINE)); if (result.length() > 0) { result += Utils.NEW_LINE; } return result; } --- 54,76 ---- } Pattern splitOut = Pattern.compile("\\n"); // tests use \n only in stdout Pattern splitErr = Pattern.compile("\\r?\\n"); // can handle both \r\n and \n Path testDir = Paths.get(Utils.TEST_SRC); ! String goldOut = formatOutput(streamGoldFile(testDir, args[0], "out")); ! String anlzOut = formatOutput(Arrays.stream(splitOut.split(oa.getStdout()))); Asserts.assertEQ(anlzOut, goldOut, "Actual stdout isn't equal to golden one"); ! String goldErr = formatOutput(streamGoldFile(testDir, args[0], "err")); ! String anlzErr = formatOutput(Arrays.stream(splitErr.split(oa.getStderr()))); Asserts.assertEQ(anlzErr, goldErr, "Actual stderr isn't equal to golden one"); int exitValue = Integer.parseInt(streamGoldFile(testDir, args[0], "exit").findFirst().get()); oa.shouldHaveExitValue(exitValue); } ! private static String formatOutput(Stream<String> stream) { ! String result = stream.collect(Collectors.joining(Utils.NEW_LINE)); if (result.length() > 0) { result += Utils.NEW_LINE; } return result; }
< prev index next >