Skip to content

Commit

Permalink
Stop skipping tests that look for line breaks under Windows.
Browse files Browse the repository at this point in the history
Fixes #6560

Progress toward #2130

RELNOTES=n/a
PiperOrigin-RevId: 542323657
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jun 21, 2023
1 parent b2054e1 commit 3286f01
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.common.base;

import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static com.google.common.base.Throwables.lazyStackTrace;
import static com.google.common.base.Throwables.lazyStackTraceIsLazy;
Expand Down Expand Up @@ -658,9 +657,6 @@ static void methodThatThrowsUndeclaredChecked() throws SomeUndeclaredCheckedExce
@J2ktIncompatible
@GwtIncompatible // getStackTraceAsString(Throwable)
public void testGetStackTraceAsString() {
if (isWindows()) {
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
}
class StackTraceException extends Exception {
StackTraceException(String message) {
super(message);
Expand All @@ -671,8 +667,9 @@ class StackTraceException extends Exception {

String firstLine = quote(e.getClass().getName() + ": " + e.getMessage());
String secondLine = "\\s*at " + ThrowablesTest.class.getName() + "\\..*";
String moreLines = "(?:.*\n?)*";
String expected = firstLine + "\n" + secondLine + "\n" + moreLines;
String moreLines = "(?:.*" + System.lineSeparator() + "?)*";
String expected =
firstLine + System.lineSeparator() + secondLine + System.lineSeparator() + moreLines;
assertThat(getStackTraceAsString(e)).matches(expected);
}

Expand Down Expand Up @@ -792,8 +789,4 @@ private void doTestLazyStackTraceFallback() {
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(Throwables.class);
}

private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.common.io;

import static com.google.common.base.CharMatcher.whitespace;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Charsets;
Expand Down Expand Up @@ -160,10 +159,7 @@ public void testGetResource_contextClassLoader() throws IOException {
Thread.currentThread().setContextClassLoader(loader);
URL url = Resources.getResource(tempFile.getName());
String text = Resources.toString(url, Charsets.UTF_8);
if (isWindows()) {
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
}
assertEquals("rud a chur ar an méar fhada\n", text);
assertEquals("rud a chur ar an méar fhada" + System.lineSeparator(), text);
} finally {
Thread.currentThread().setContextClassLoader(oldContextLoader);
}
Expand Down Expand Up @@ -194,8 +190,4 @@ public void testNulls() {
private static URL classfile(Class<?> c) {
return c.getResource(c.getSimpleName() + ".class");
}

private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
}
13 changes: 3 additions & 10 deletions guava-tests/test/com/google/common/base/ThrowablesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.common.base;

import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static com.google.common.base.Throwables.lazyStackTrace;
import static com.google.common.base.Throwables.lazyStackTraceIsLazy;
Expand Down Expand Up @@ -658,9 +657,6 @@ static void methodThatThrowsUndeclaredChecked() throws SomeUndeclaredCheckedExce
@J2ktIncompatible
@GwtIncompatible // getStackTraceAsString(Throwable)
public void testGetStackTraceAsString() {
if (isWindows()) {
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
}
class StackTraceException extends Exception {
StackTraceException(String message) {
super(message);
Expand All @@ -671,8 +667,9 @@ class StackTraceException extends Exception {

String firstLine = quote(e.getClass().getName() + ": " + e.getMessage());
String secondLine = "\\s*at " + ThrowablesTest.class.getName() + "\\..*";
String moreLines = "(?:.*\n?)*";
String expected = firstLine + "\n" + secondLine + "\n" + moreLines;
String moreLines = "(?:.*" + System.lineSeparator() + "?)*";
String expected =
firstLine + System.lineSeparator() + secondLine + System.lineSeparator() + moreLines;
assertThat(getStackTraceAsString(e)).matches(expected);
}

Expand Down Expand Up @@ -792,8 +789,4 @@ private void doTestLazyStackTraceFallback() {
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(Throwables.class);
}

private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
}
10 changes: 1 addition & 9 deletions guava-tests/test/com/google/common/io/ResourcesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.google.common.io;

import static com.google.common.base.CharMatcher.whitespace;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Charsets;
Expand Down Expand Up @@ -160,10 +159,7 @@ public void testGetResource_contextClassLoader() throws IOException {
Thread.currentThread().setContextClassLoader(loader);
URL url = Resources.getResource(tempFile.getName());
String text = Resources.toString(url, Charsets.UTF_8);
if (isWindows()) {
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
}
assertEquals("rud a chur ar an méar fhada\n", text);
assertEquals("rud a chur ar an méar fhada" + System.lineSeparator(), text);
} finally {
Thread.currentThread().setContextClassLoader(oldContextLoader);
}
Expand Down Expand Up @@ -194,8 +190,4 @@ public void testNulls() {
private static URL classfile(Class<?> c) {
return c.getResource(c.getSimpleName() + ".class");
}

private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
}

1 comment on commit 3286f01

@cpovirk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake: This commit should have been credited to @ineuwirth.

Please sign in to comment.