Try to fix Windows build failures
Text blocks use \n as their separator on all platforms. Update withLineSeparatorUsesLineSeparator() to replace \n rather than System.lineSeparator() createPrinterWhenStandardAppliesCustomizations() limits the length of the output. On Windows, the default \r\n line separator uses an extra byte per separator compared to \n. Configure the printer to use \n as a line separator so that non-whitespace output is the same on all platforms. See gh-43864
This commit is contained in:
@@ -263,8 +263,7 @@ class StandardStackTracePrinterTests {
|
||||
void withLineSeparatorUsesLineSeparator() {
|
||||
Throwable exception = TestException.create();
|
||||
StandardStackTracePrinter printer = StandardStackTracePrinter.rootLast().withLineSeparator("!");
|
||||
assertThatCleanedStackTraceMatches(printer, exception,
|
||||
standardStackTrace().replace(System.lineSeparator(), "!"));
|
||||
assertThatCleanedStackTraceMatches(printer, exception, standardStackTrace().replace("\n", "!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -144,7 +144,8 @@ class StructuredLoggingJsonPropertiesTests {
|
||||
void createPrinterWhenStandardAppliesCustomizations() {
|
||||
Exception exception = TestException.create();
|
||||
StackTrace properties = new StackTrace(null, Root.FIRST, 300, 2, true, false);
|
||||
StackTracePrinter printer = properties.createPrinter();
|
||||
StackTracePrinter printer = ((StandardStackTracePrinter) properties.createPrinter())
|
||||
.withLineSeparator("\n");
|
||||
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
|
||||
assertThat(actual).isEqualToNormalizingNewlines("""
|
||||
java.lang.RuntimeException: exception
|
||||
|
||||
Reference in New Issue
Block a user