Skip to content

Commit

Permalink
Run CI under Windows, suppressing existing failures.
Browse files Browse the repository at this point in the history
- Fixes #2686
- In some sense addresses #2130, but I'm going to leave that open to track removing the suppressions.
- Provides better testing for the fix for #6535

RELNOTES=n/a
PiperOrigin-RevId: 538841996
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jun 8, 2023
1 parent 9916d82 commit 6db7d68
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ jobs:
permissions:
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
contents: read # for actions/checkout to fetch code
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }}"
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }} on ${{ matrix.os }}"
strategy:
matrix:
os: [ ubuntu-latest ]
java: [ 8, 11, 17 ]
root-pom: [ 'pom.xml', 'android/pom.xml' ]
runs-on: ubuntu-latest
include:
- os: windows-latest
java: 17
root-pom: pom.xml
runs-on: ${{ matrix.os }}
env:
ROOT_POM: ${{ matrix.root-pom }}
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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 @@ -657,6 +658,9 @@ 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 Down Expand Up @@ -788,4 +792,8 @@ 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 @@ -16,6 +16,7 @@

package com.google.common.io;

import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.io.FileBackedOutputStreamTest.write;

import com.google.common.testing.GcFinalization;
Expand All @@ -30,6 +31,9 @@
public class FileBackedOutputStreamAndroidIncompatibleTest extends IoTestCase {

public void testFinalizeDeletesFile() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);

Expand All @@ -51,4 +55,8 @@ public boolean isDone() {
}
});
}

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

import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
Expand All @@ -40,6 +41,9 @@ public class FileBackedOutputStreamTest extends IoTestCase {


public void testThreshold() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
testThreshold(0, 100, true, false);
testThreshold(10, 100, true, false);
testThreshold(100, 100, true, false);
Expand Down Expand Up @@ -99,6 +103,9 @@ private void testThreshold(


public void testThreshold_resetOnFinalize() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
testThreshold(0, 100, true, true);
testThreshold(10, 100, true, true);
testThreshold(100, 100, true, true);
Expand All @@ -124,6 +131,9 @@ static void write(OutputStream out, byte[] b, int off, int len, boolean singleBy
// TODO(chrisn): only works if we ensure we have crossed file threshold

public void testWriteErrorAfterClose() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(50);
ByteSource source = out.asByteSource();
Expand Down Expand Up @@ -167,4 +177,8 @@ public void testReset() throws Exception {
private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}

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

import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE;
import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
Expand All @@ -38,6 +39,9 @@
@SuppressWarnings("deprecation") // tests of a deprecated method
public class FilesCreateTempDirTest extends TestCase {
public void testCreateTempDir() throws IOException {
if (isWindows()) {
return; // TODO: b/285742623 - Fix Files.createTempDir under Windows.
}
if (JAVA_IO_TMPDIR.value().equals("/sdcard")) {
assertThrows(IllegalStateException.class, Files::createTempDir);
return;
Expand All @@ -63,4 +67,8 @@ public void testCreateTempDir() throws IOException {
private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}

private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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 @@ -159,6 +160,9 @@ 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);
} finally {
Thread.currentThread().setContextClassLoader(oldContextLoader);
Expand Down Expand Up @@ -190,4 +194,8 @@ 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.google.common.base.Charsets.US_ASCII;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.common.truth.Truth.assertThat;

Expand Down Expand Up @@ -173,6 +174,13 @@ public void testToFile_AndroidIncompatible() throws Exception {
@AndroidIncompatible // Android forbids null parent ClassLoader
// https://github.com/google/guava/issues/2152
public void testJarFileWithSpaces() throws Exception {
if (isWindows()) {
/*
* TODO: b/285742623 - Fix c.g.c.io.Files.createTempDir under Windows. Or use java.nio.files
* instead?
*/
return;
}
URL url = makeJarUrlWithName("To test unescaped spaces in jar file name.jar");
URLClassLoader classloader = new URLClassLoader(new URL[] {url}, null);
assertThat(ClassPath.from(classloader).getTopLevelClasses()).isNotEmpty();
Expand Down Expand Up @@ -215,6 +223,9 @@ public void testScanFromFile_notJarFile() throws IOException {
}

public void testGetClassPathEntry() throws MalformedURLException, URISyntaxException {
if (isWindows()) {
return; // TODO: b/136041958 - We need to account for drive letters in the path.
}
assertEquals(
new File("/usr/test/dep.jar").toURI(),
ClassPath.getClassPathEntry(new File("/home/build/outer.jar"), "file:/usr/test/dep.jar")
Expand Down Expand Up @@ -285,20 +296,29 @@ public void testGetClassPathFromManifest_jarInCurrentDirectory() throws IOExcept
}

public void testGetClassPathFromManifest_absoluteDirectory() throws IOException {
if (isWindows()) {
return; // TODO: b/136041958 - We need to account for drive letters in the path.
}
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute/dir");
assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("/with/absolute/dir"));
}

public void testGetClassPathFromManifest_absoluteJar() throws IOException {
if (isWindows()) {
return; // TODO: b/136041958 - We need to account for drive letters in the path.
}
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute.jar");
assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
.containsExactly(fullpath("/with/absolute.jar"));
}

public void testGetClassPathFromManifest_multiplePaths() throws IOException {
if (isWindows()) {
return; // TODO: b/136041958 - We need to account for drive letters in the path.
}
File jarFile = new File("base/some.jar");
Manifest manifest = manifestClasspath("file:/with/absolute.jar relative.jar relative/dir");
assertThat(ClassPath.getClassPathFromManifest(jarFile, manifest))
Expand Down Expand Up @@ -355,6 +375,9 @@ public void testGetPackageName() {


public void testGetClassPathUrls() throws Exception {
if (isWindows()) {
return; // TODO: b/136041958 - We need to account for drive letters in the path.
}
String oldPathSeparator = PATH_SEPARATOR.value();
String oldClassPath = JAVA_CLASS_PATH.value();
System.setProperty(PATH_SEPARATOR.key(), ":");
Expand Down Expand Up @@ -572,4 +595,8 @@ private static ImmutableSet<String> scanResourceNames(ClassLoader loader) throws
}
return builder.build();
}

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

import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

Expand Down Expand Up @@ -436,6 +437,9 @@ public void run() {
*/

public void testFutureBash() {
if (isWindows()) {
return; // TODO: b/136041958 - This test is very slow. Or at least I assume it's this one....
}
final CyclicBarrier barrier =
new CyclicBarrier(
6 // for the setter threads
Expand Down Expand Up @@ -1325,4 +1329,8 @@ protected void interruptTask() {
interruptTaskWasCalled = true;
}
}

private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
}
8 changes: 8 additions & 0 deletions guava-tests/test/com/google/common/base/ThrowablesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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 @@ -657,6 +658,9 @@ 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 Down Expand Up @@ -788,4 +792,8 @@ 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 @@ -16,6 +16,7 @@

package com.google.common.io;

import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.io.FileBackedOutputStreamTest.write;

import com.google.common.testing.GcFinalization;
Expand All @@ -30,6 +31,9 @@
public class FileBackedOutputStreamAndroidIncompatibleTest extends IoTestCase {

public void testFinalizeDeletesFile() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(0, true);

Expand All @@ -51,4 +55,8 @@ public boolean isDone() {
}
});
}

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

import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE;
Expand All @@ -40,6 +41,9 @@ public class FileBackedOutputStreamTest extends IoTestCase {


public void testThreshold() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
testThreshold(0, 100, true, false);
testThreshold(10, 100, true, false);
testThreshold(100, 100, true, false);
Expand Down Expand Up @@ -99,6 +103,9 @@ private void testThreshold(


public void testThreshold_resetOnFinalize() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
testThreshold(0, 100, true, true);
testThreshold(10, 100, true, true);
testThreshold(100, 100, true, true);
Expand All @@ -124,6 +131,9 @@ static void write(OutputStream out, byte[] b, int off, int len, boolean singleBy
// TODO(chrisn): only works if we ensure we have crossed file threshold

public void testWriteErrorAfterClose() throws Exception {
if (isWindows()) {
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
}
byte[] data = newPreFilledByteArray(100);
FileBackedOutputStream out = new FileBackedOutputStream(50);
ByteSource source = out.asByteSource();
Expand Down Expand Up @@ -167,4 +177,8 @@ public void testReset() throws Exception {
private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}

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

0 comments on commit 6db7d68

Please sign in to comment.