From 6db7d687c5226e8530f9a74122ece73fae835163 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Thu, 8 Jun 2023 11:23:05 -0700 Subject: [PATCH] Run CI under Windows, suppressing existing failures. - Fixes https://github.com/google/guava/issues/2686 - In some sense addresses https://github.com/google/guava/issues/2130, but I'm going to leave that open to track removing the suppressions. - Provides better testing for the fix for https://github.com/google/guava/issues/6535 RELNOTES=n/a PiperOrigin-RevId: 538841996 --- .github/workflows/ci.yml | 9 +++-- .../google/common/base/ThrowablesTest.java | 8 +++++ ...edOutputStreamAndroidIncompatibleTest.java | 8 +++++ .../common/io/FileBackedOutputStreamTest.java | 14 ++++++++ .../common/io/FilesCreateTempDirTest.java | 8 +++++ .../com/google/common/io/ResourcesTest.java | 8 +++++ .../google/common/reflect/ClassPathTest.java | 27 +++++++++++++++ .../util/concurrent/AbstractFutureTest.java | 8 +++++ .../google/common/base/ThrowablesTest.java | 8 +++++ ...edOutputStreamAndroidIncompatibleTest.java | 8 +++++ .../common/io/FileBackedOutputStreamTest.java | 14 ++++++++ .../common/io/FilesCreateTempDirTest.java | 8 +++++ .../com/google/common/io/MoreFilesTest.java | 8 +++++ .../com/google/common/io/ResourcesTest.java | 8 +++++ .../google/common/reflect/ClassPathTest.java | 33 +++++++++++++++++++ .../util/concurrent/AbstractFutureTest.java | 8 +++++ 16 files changed, 183 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f754437caf76..485a3d403e145 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/android/guava-tests/test/com/google/common/base/ThrowablesTest.java b/android/guava-tests/test/com/google/common/base/ThrowablesTest.java index d04c358be8d86..363550a16e597 100644 --- a/android/guava-tests/test/com/google/common/base/ThrowablesTest.java +++ b/android/guava-tests/test/com/google/common/base/ThrowablesTest.java @@ -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; @@ -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); @@ -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"); + } } diff --git a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java index 4ecdcf8d5688d..9d25e42affb32 100644 --- a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java +++ b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java @@ -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; @@ -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); @@ -51,4 +55,8 @@ public boolean isDone() { } }); } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } } diff --git a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java index 87247e1ed4d5b..2924cc081909d 100644 --- a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java +++ b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java @@ -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; @@ -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); @@ -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); @@ -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(); @@ -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"); + } } diff --git a/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java b/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java index 62098ef0288ae..228891d272551 100644 --- a/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java +++ b/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java @@ -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; @@ -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; @@ -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"); + } } diff --git a/android/guava-tests/test/com/google/common/io/ResourcesTest.java b/android/guava-tests/test/com/google/common/io/ResourcesTest.java index 0b51c9986f88b..23a487530a332 100644 --- a/android/guava-tests/test/com/google/common/io/ResourcesTest.java +++ b/android/guava-tests/test/com/google/common/io/ResourcesTest.java @@ -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; @@ -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); @@ -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"); + } } diff --git a/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java b/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java index 0184ed89135de..f2de67c19b288 100644 --- a/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java +++ b/android/guava-tests/test/com/google/common/reflect/ClassPathTest.java @@ -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; @@ -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(); @@ -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") @@ -285,6 +296,9 @@ 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)) @@ -292,6 +306,9 @@ public void testGetClassPathFromManifest_absoluteDirectory() throws IOException } 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)) @@ -299,6 +316,9 @@ public void testGetClassPathFromManifest_absoluteJar() throws IOException { } 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)) @@ -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(), ":"); @@ -572,4 +595,8 @@ private static ImmutableSet scanResourceNames(ClassLoader loader) throws } return builder.build(); } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } } diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java index 0ed399b726adc..d0224fcc1d11e 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java @@ -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; @@ -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 @@ -1325,4 +1329,8 @@ protected void interruptTask() { interruptTaskWasCalled = true; } } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } } diff --git a/guava-tests/test/com/google/common/base/ThrowablesTest.java b/guava-tests/test/com/google/common/base/ThrowablesTest.java index d04c358be8d86..363550a16e597 100644 --- a/guava-tests/test/com/google/common/base/ThrowablesTest.java +++ b/guava-tests/test/com/google/common/base/ThrowablesTest.java @@ -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; @@ -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); @@ -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"); + } } diff --git a/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java b/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java index 4ecdcf8d5688d..9d25e42affb32 100644 --- a/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java +++ b/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java @@ -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; @@ -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); @@ -51,4 +55,8 @@ public boolean isDone() { } }); } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } } diff --git a/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java b/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java index 87247e1ed4d5b..2924cc081909d 100644 --- a/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java +++ b/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java @@ -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; @@ -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); @@ -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); @@ -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(); @@ -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"); + } } diff --git a/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java b/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java index 62098ef0288ae..228891d272551 100644 --- a/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java +++ b/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java @@ -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; @@ -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; @@ -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"); + } } diff --git a/guava-tests/test/com/google/common/io/MoreFilesTest.java b/guava-tests/test/com/google/common/io/MoreFilesTest.java index 005cf531da543..e669bf7ddfc4b 100644 --- a/guava-tests/test/com/google/common/io/MoreFilesTest.java +++ b/guava-tests/test/com/google/common/io/MoreFilesTest.java @@ -16,6 +16,7 @@ package com.google.common.io; +import static com.google.common.base.StandardSystemProperty.OS_NAME; import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE; import static com.google.common.jimfs.Feature.SECURE_DIRECTORY_STREAM; import static com.google.common.jimfs.Feature.SYMBOLIC_LINKS; @@ -301,6 +302,9 @@ public void testCreateParentDirectories_multipleParentsNeeded() throws IOExcepti } public void testCreateParentDirectories_noPermission() { + if (isWindows()) { + return; // TODO: b/136041958 - Create/find a directory that we don't have permissions on? + } Path file = root().resolve("parent/nonexistent.file"); Path parent = file.getParent(); assertFalse(Files.exists(parent)); @@ -721,4 +725,8 @@ public void assertDeleteSucceeded(Path path) throws IOException { public abstract void assertDeleteSucceeded(Path path) throws IOException; } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } } diff --git a/guava-tests/test/com/google/common/io/ResourcesTest.java b/guava-tests/test/com/google/common/io/ResourcesTest.java index 0b51c9986f88b..23a487530a332 100644 --- a/guava-tests/test/com/google/common/io/ResourcesTest.java +++ b/guava-tests/test/com/google/common/io/ResourcesTest.java @@ -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; @@ -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); @@ -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"); + } } diff --git a/guava-tests/test/com/google/common/reflect/ClassPathTest.java b/guava-tests/test/com/google/common/reflect/ClassPathTest.java index 3d78e7b24a06d..587419576b727 100644 --- a/guava-tests/test/com/google/common/reflect/ClassPathTest.java +++ b/guava-tests/test/com/google/common/reflect/ClassPathTest.java @@ -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.io.MoreFiles.deleteRecursively; import static com.google.common.truth.Truth.assertThat; @@ -179,6 +180,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(); @@ -202,6 +210,9 @@ public void testScan_classPathCycle() throws IOException { @AndroidIncompatible // Path (for symlink creation) public void testScanDirectory_symlinkCycle() throws IOException { + if (isWindows()) { + return; // TODO: b/136041958 - Can we detect cycles under Windows? + } ClassLoader loader = ClassPathTest.class.getClassLoader(); // directory with a cycle, // /root @@ -234,6 +245,9 @@ public void testScanDirectory_symlinkCycle() throws IOException { @AndroidIncompatible // Path (for symlink creation) public void testScanDirectory_symlinkToRootCycle() throws IOException { + if (isWindows()) { + return; // TODO: b/136041958 - Can we detect cycles under Windows? + } ClassLoader loader = ClassPathTest.class.getClassLoader(); // directory with a cycle, // /root @@ -274,6 +288,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") @@ -344,6 +361,9 @@ 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)) @@ -351,6 +371,9 @@ public void testGetClassPathFromManifest_absoluteDirectory() throws IOException } 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)) @@ -358,6 +381,9 @@ public void testGetClassPathFromManifest_absoluteJar() throws IOException { } 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)) @@ -414,6 +440,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(), ":"); @@ -640,4 +669,8 @@ private static ImmutableSet scanResourceNames(ClassLoader loader) throws } return builder.build(); } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } } diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java index 0ed399b726adc..d0224fcc1d11e 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java @@ -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; @@ -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 @@ -1325,4 +1329,8 @@ protected void interruptTask() { interruptTaskWasCalled = true; } } + + private static boolean isWindows() { + return OS_NAME.value().startsWith("Windows"); + } }