Skip to content

Commit 6db7d68

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committed
Run CI under Windows, suppressing existing failures.
- 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
1 parent 9916d82 commit 6db7d68

16 files changed

+183
-2
lines changed

.github/workflows/ci.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ jobs:
1616
permissions:
1717
actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows
1818
contents: read # for actions/checkout to fetch code
19-
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }}"
19+
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }} on ${{ matrix.os }}"
2020
strategy:
2121
matrix:
22+
os: [ ubuntu-latest ]
2223
java: [ 8, 11, 17 ]
2324
root-pom: [ 'pom.xml', 'android/pom.xml' ]
24-
runs-on: ubuntu-latest
25+
include:
26+
- os: windows-latest
27+
java: 17
28+
root-pom: pom.xml
29+
runs-on: ${{ matrix.os }}
2530
env:
2631
ROOT_POM: ${{ matrix.root-pom }}
2732
steps:

android/guava-tests/test/com/google/common/base/ThrowablesTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.base;
1818

1919
import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
20+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
2021
import static com.google.common.base.Throwables.getStackTraceAsString;
2122
import static com.google.common.base.Throwables.lazyStackTrace;
2223
import static com.google.common.base.Throwables.lazyStackTraceIsLazy;
@@ -657,6 +658,9 @@ static void methodThatThrowsUndeclaredChecked() throws SomeUndeclaredCheckedExce
657658
@J2ktIncompatible
658659
@GwtIncompatible // getStackTraceAsString(Throwable)
659660
public void testGetStackTraceAsString() {
661+
if (isWindows()) {
662+
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
663+
}
660664
class StackTraceException extends Exception {
661665
StackTraceException(String message) {
662666
super(message);
@@ -788,4 +792,8 @@ private void doTestLazyStackTraceFallback() {
788792
public void testNullPointers() {
789793
new NullPointerTester().testAllPublicStaticMethods(Throwables.class);
790794
}
795+
796+
private static boolean isWindows() {
797+
return OS_NAME.value().startsWith("Windows");
798+
}
791799
}

android/guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.common.io;
1818

19+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
1920
import static com.google.common.io.FileBackedOutputStreamTest.write;
2021

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

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

@@ -51,4 +55,8 @@ public boolean isDone() {
5155
}
5256
});
5357
}
58+
59+
private static boolean isWindows() {
60+
return OS_NAME.value().startsWith("Windows");
61+
}
5462
}

android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.io;
1818

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

4142

4243
public void testThreshold() throws Exception {
44+
if (isWindows()) {
45+
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
46+
}
4347
testThreshold(0, 100, true, false);
4448
testThreshold(10, 100, true, false);
4549
testThreshold(100, 100, true, false);
@@ -99,6 +103,9 @@ private void testThreshold(
99103

100104

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

126133
public void testWriteErrorAfterClose() throws Exception {
134+
if (isWindows()) {
135+
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
136+
}
127137
byte[] data = newPreFilledByteArray(100);
128138
FileBackedOutputStream out = new FileBackedOutputStream(50);
129139
ByteSource source = out.asByteSource();
@@ -167,4 +177,8 @@ public void testReset() throws Exception {
167177
private static boolean isAndroid() {
168178
return System.getProperty("java.runtime.name", "").contains("Android");
169179
}
180+
181+
private static boolean isWindows() {
182+
return OS_NAME.value().startsWith("Windows");
183+
}
170184
}

android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.io;
1818

1919
import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
20+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
2021
import static com.google.common.truth.Truth.assertThat;
2122
import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE;
2223
import static java.nio.file.attribute.PosixFilePermission.OWNER_READ;
@@ -38,6 +39,9 @@
3839
@SuppressWarnings("deprecation") // tests of a deprecated method
3940
public class FilesCreateTempDirTest extends TestCase {
4041
public void testCreateTempDir() throws IOException {
42+
if (isWindows()) {
43+
return; // TODO: b/285742623 - Fix Files.createTempDir under Windows.
44+
}
4145
if (JAVA_IO_TMPDIR.value().equals("/sdcard")) {
4246
assertThrows(IllegalStateException.class, Files::createTempDir);
4347
return;
@@ -63,4 +67,8 @@ public void testCreateTempDir() throws IOException {
6367
private static boolean isAndroid() {
6468
return System.getProperty("java.runtime.name", "").contains("Android");
6569
}
70+
71+
private static boolean isWindows() {
72+
return OS_NAME.value().startsWith("Windows");
73+
}
6674
}

android/guava-tests/test/com/google/common/io/ResourcesTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.io;
1818

1919
import static com.google.common.base.CharMatcher.whitespace;
20+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
2021
import static com.google.common.truth.Truth.assertThat;
2122

2223
import com.google.common.base.Charsets;
@@ -159,6 +160,9 @@ public void testGetResource_contextClassLoader() throws IOException {
159160
Thread.currentThread().setContextClassLoader(loader);
160161
URL url = Resources.getResource(tempFile.getName());
161162
String text = Resources.toString(url, Charsets.UTF_8);
163+
if (isWindows()) {
164+
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
165+
}
162166
assertEquals("rud a chur ar an méar fhada\n", text);
163167
} finally {
164168
Thread.currentThread().setContextClassLoader(oldContextLoader);
@@ -190,4 +194,8 @@ public void testNulls() {
190194
private static URL classfile(Class<?> c) {
191195
return c.getResource(c.getSimpleName() + ".class");
192196
}
197+
198+
private static boolean isWindows() {
199+
return OS_NAME.value().startsWith("Windows");
200+
}
193201
}

android/guava-tests/test/com/google/common/reflect/ClassPathTest.java

+27
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static com.google.common.base.Charsets.US_ASCII;
1919
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
20+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
2021
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
2122
import static com.google.common.truth.Truth.assertThat;
2223

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

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

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

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

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

356376

357377
public void testGetClassPathUrls() throws Exception {
378+
if (isWindows()) {
379+
return; // TODO: b/136041958 - We need to account for drive letters in the path.
380+
}
358381
String oldPathSeparator = PATH_SEPARATOR.value();
359382
String oldClassPath = JAVA_CLASS_PATH.value();
360383
System.setProperty(PATH_SEPARATOR.key(), ":");
@@ -572,4 +595,8 @@ private static ImmutableSet<String> scanResourceNames(ClassLoader loader) throws
572595
}
573596
return builder.build();
574597
}
598+
599+
private static boolean isWindows() {
600+
return OS_NAME.value().startsWith("Windows");
601+
}
575602
}

android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.util.concurrent;
1818

1919
import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
20+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
2021
import static com.google.common.truth.Truth.assertThat;
2122
import static com.google.common.truth.Truth.assertWithMessage;
2223

@@ -436,6 +437,9 @@ public void run() {
436437
*/
437438

438439
public void testFutureBash() {
440+
if (isWindows()) {
441+
return; // TODO: b/136041958 - This test is very slow. Or at least I assume it's this one....
442+
}
439443
final CyclicBarrier barrier =
440444
new CyclicBarrier(
441445
6 // for the setter threads
@@ -1325,4 +1329,8 @@ protected void interruptTask() {
13251329
interruptTaskWasCalled = true;
13261330
}
13271331
}
1332+
1333+
private static boolean isWindows() {
1334+
return OS_NAME.value().startsWith("Windows");
1335+
}
13281336
}

guava-tests/test/com/google/common/base/ThrowablesTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.base;
1818

1919
import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
20+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
2021
import static com.google.common.base.Throwables.getStackTraceAsString;
2122
import static com.google.common.base.Throwables.lazyStackTrace;
2223
import static com.google.common.base.Throwables.lazyStackTraceIsLazy;
@@ -657,6 +658,9 @@ static void methodThatThrowsUndeclaredChecked() throws SomeUndeclaredCheckedExce
657658
@J2ktIncompatible
658659
@GwtIncompatible // getStackTraceAsString(Throwable)
659660
public void testGetStackTraceAsString() {
661+
if (isWindows()) {
662+
return; // TODO: b/136041958 - We probably just need to accept \r\n line delimiters.
663+
}
660664
class StackTraceException extends Exception {
661665
StackTraceException(String message) {
662666
super(message);
@@ -788,4 +792,8 @@ private void doTestLazyStackTraceFallback() {
788792
public void testNullPointers() {
789793
new NullPointerTester().testAllPublicStaticMethods(Throwables.class);
790794
}
795+
796+
private static boolean isWindows() {
797+
return OS_NAME.value().startsWith("Windows");
798+
}
791799
}

guava-tests/test/com/google/common/io/FileBackedOutputStreamAndroidIncompatibleTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.common.io;
1818

19+
import static com.google.common.base.StandardSystemProperty.OS_NAME;
1920
import static com.google.common.io.FileBackedOutputStreamTest.write;
2021

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

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

@@ -51,4 +55,8 @@ public boolean isDone() {
5155
}
5256
});
5357
}
58+
59+
private static boolean isWindows() {
60+
return OS_NAME.value().startsWith("Windows");
61+
}
5462
}

guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.common.io;
1818

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

4142

4243
public void testThreshold() throws Exception {
44+
if (isWindows()) {
45+
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
46+
}
4347
testThreshold(0, 100, true, false);
4448
testThreshold(10, 100, true, false);
4549
testThreshold(100, 100, true, false);
@@ -99,6 +103,9 @@ private void testThreshold(
99103

100104

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

126133
public void testWriteErrorAfterClose() throws Exception {
134+
if (isWindows()) {
135+
return; // TODO: b/285742623 - Fix FileBackedOutputStream under Windows.
136+
}
127137
byte[] data = newPreFilledByteArray(100);
128138
FileBackedOutputStream out = new FileBackedOutputStream(50);
129139
ByteSource source = out.asByteSource();
@@ -167,4 +177,8 @@ public void testReset() throws Exception {
167177
private static boolean isAndroid() {
168178
return System.getProperty("java.runtime.name", "").contains("Android");
169179
}
180+
181+
private static boolean isWindows() {
182+
return OS_NAME.value().startsWith("Windows");
183+
}
170184
}

0 commit comments

Comments
 (0)