Skip to content

Commit 9dec7ba

Browse files
committed
Do the tests still work on Windows?
1 parent d5cea69 commit 9dec7ba

File tree

8 files changed

+52
-21
lines changed

8 files changed

+52
-21
lines changed

Jenkinsfile

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ properties([
1818
disableConcurrentBuilds(abortPrevious: true)
1919
])
2020

21-
// TODO: Restore 'Windows' once https://groups.google.com/forum/#!topic/jenkinsci-dev/v9d-XosOp2s is resolved
22-
def buildTypes = ['Linux']
23-
def jdks = [8, 11]
21+
def buildTypes = ['Windows']
22+
def jdks = [11]
2423

2524
def builds = [:]
2625
for(i = 0; i < buildTypes.size(); i++) {
@@ -29,7 +28,11 @@ for(j = 0; j < jdks.size(); j++) {
2928
def jdk = jdks[j]
3029
builds["${buildType}-jdk${jdk}"] = {
3130
// see https://github.com/jenkins-infra/documentation/blob/master/ci.adoc#node-labels for information on what node types are available
32-
node(buildType == 'Linux' ? (jdk == 8 ? 'maven' : 'maven-11') : buildType.toLowerCase()) {
31+
String agentContainerLabel = jdk == '8' ? 'maven' : 'maven-11'
32+
if (buildType == 'Windows') {
33+
agentContainerLabel += '-windows'
34+
}
35+
node(agentContainerLabel) {
3336
// First stage is actually checking out the source. Since we're using Multibranch
3437
// currently, we can use "checkout scm".
3538
stage('Checkout') {
@@ -68,7 +71,7 @@ for(j = 0; j < jdks.size(); j++) {
6871
error 'There were test failures; halting early'
6972
}
7073
}
71-
if (buildType == 'Linux' && jdk == jdks[0]) {
74+
if (buildType == 'Windows' && jdk == jdks[0]) {
7275
def folders = env.JOB_NAME.split('/')
7376
if (folders.length > 1) {
7477
discoverGitReferenceBuild(scm: folders[1])

core/src/test/java/hudson/FilePathTest.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ private void checkTarUntarRoundTrip(String filePrefix, long fileSize) throws Exc
478478
}
479479

480480
@Test public void copyToWithPermissionSpecialPermissions() throws IOException, InterruptedException {
481-
assumeFalse("Test uses POSIX-specific features", Functions.isWindows() || Platform.isDarwin());
481+
assumeFalse(Functions.isWindows() || Platform.isDarwin());
482482
File tmp = temp.getRoot();
483483
File original = new File(tmp,"original");
484484
FilePath originalP = new FilePath(channels.french, original.getPath());
@@ -497,7 +497,7 @@ private void checkTarUntarRoundTrip(String filePrefix, long fileSize) throws Exc
497497
}
498498

499499
@Test public void symlinkInTar() throws Exception {
500-
assumeFalse("can't test on Windows", Functions.isWindows());
500+
assumeFalse(Functions.isWindows());
501501

502502
FilePath tmp = new FilePath(temp.getRoot());
503503
FilePath in = tmp.child("in");
@@ -805,7 +805,7 @@ public void testCreateTempDir() throws IOException, InterruptedException {
805805
}
806806

807807
@Test public void deleteRecursiveOnUnix() throws Exception {
808-
assumeFalse("Uses Unix-specific features", Functions.isWindows());
808+
assumeFalse(Functions.isWindows());
809809
Path targetDir = temp.newFolder("target").toPath();
810810
Path targetContents = Files.createFile(targetDir.resolve("contents.txt"));
811811
Path toDelete = temp.newFolder("toDelete").toPath();
@@ -851,7 +851,7 @@ public void deleteSuffixesRecursive() throws Exception {
851851

852852
@Issue("JENKINS-13128")
853853
@Test public void copyRecursivePreservesPosixFilePermissions() throws Exception {
854-
assumeFalse("windows doesn't support posix file permissions", Functions.isWindows());
854+
assumeFalse(Functions.isWindows());
855855
File src = temp.newFolder("src");
856856
File dst = temp.newFolder("dst");
857857
Path sourceFile = Files.createFile(src.toPath().resolve("test-file"));
@@ -932,6 +932,7 @@ public void isDescendant_regularFiles() throws IOException, InterruptedException
932932
@Test
933933
@Issue("SECURITY-904")
934934
public void isDescendant_regularSymlinks() throws IOException, InterruptedException {
935+
assumeFalse(Functions.isWindows());
935936
// root
936937
// /workspace
937938
// /a
@@ -1086,6 +1087,7 @@ public void isDescendant_throwIfAbsolutePathGiven() throws Exception {
10861087
@Test
10871088
@Issue("SECURITY-904")
10881089
public void isDescendant_worksEvenInSymbolicWorkspace() throws Exception {
1090+
assumeFalse(Functions.isWindows());
10891091
// root
10901092
// /w
10911093
// /_workspace => symlink to ../workspace

core/src/test/java/hudson/LauncherTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static org.junit.Assert.assertNotEquals;
3030
import static org.junit.Assert.assertNull;
3131
import static org.junit.Assert.assertTrue;
32+
import static org.junit.Assume.assumeFalse;
3233

3334
import hudson.model.StreamBuildListener;
3435
import hudson.model.TaskListener;
@@ -39,7 +40,6 @@
3940
import java.nio.charset.Charset;
4041
import jenkins.security.MasterToSlaveCallable;
4142
import org.apache.commons.io.FileUtils;
42-
import org.junit.Assume;
4343
import org.junit.Rule;
4444
import org.junit.Test;
4545
import org.junit.rules.TemporaryFolder;
@@ -52,7 +52,7 @@ public class LauncherTest {
5252

5353
@Issue("JENKINS-4611")
5454
@Test public void remoteKill() throws Exception {
55-
Assume.assumeFalse("Skipping, currently Unix-specific test", Functions.isWindows());
55+
assumeFalse(Functions.isWindows());
5656

5757
File tmp = temp.newFile();
5858

core/src/test/java/hudson/UtilTest.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import static org.junit.Assert.assertNull;
3434
import static org.junit.Assert.assertTrue;
3535
import static org.junit.Assert.fail;
36+
import static org.junit.Assume.assumeFalse;
37+
import static org.junit.Assume.assumeTrue;
3638

3739
import hudson.model.TaskListener;
3840
import hudson.os.WindowsUtil;
@@ -55,7 +57,6 @@
5557
import org.hamcrest.BaseMatcher;
5658
import org.hamcrest.Description;
5759
import org.junit.Assert;
58-
import org.junit.Assume;
5960
import org.junit.Rule;
6061
import org.junit.Test;
6162
import org.junit.rules.TemporaryFolder;
@@ -223,7 +224,7 @@ public void testTryParseNumber() {
223224

224225
@Test
225226
public void testSymlink() throws Exception {
226-
Assume.assumeFalse(Functions.isWindows());
227+
assumeFalse(Functions.isWindows());
227228

228229
ByteArrayOutputStream baos = new ByteArrayOutputStream();
229230
StreamTaskListener l = new StreamTaskListener(baos);
@@ -271,7 +272,7 @@ public void testSymlink() throws Exception {
271272

272273
@Test
273274
public void testIsSymlink() throws IOException, InterruptedException {
274-
Assume.assumeFalse(Functions.isWindows());
275+
assumeFalse(Functions.isWindows());
275276

276277
ByteArrayOutputStream baos = new ByteArrayOutputStream();
277278
StreamTaskListener l = new StreamTaskListener(baos);
@@ -301,7 +302,7 @@ public void testIsSymlink() throws IOException, InterruptedException {
301302

302303
@Test
303304
public void testIsSymlink_onWindows_junction() throws Exception {
304-
Assume.assumeTrue("Uses Windows-specific features", Functions.isWindows());
305+
assumeTrue("Uses Windows-specific features", Functions.isWindows());
305306
File targetDir = tmp.newFolder("targetDir");
306307
File d = tmp.newFolder("dir");
307308
File junction = WindowsUtil.createJunction(new File(d, "junction"), targetDir);
@@ -311,7 +312,7 @@ public void testIsSymlink_onWindows_junction() throws Exception {
311312
@Test
312313
@Issue("JENKINS-55448")
313314
public void testIsSymlink_ParentIsJunction() throws IOException, InterruptedException {
314-
Assume.assumeTrue("Uses Windows-specific features", Functions.isWindows());
315+
assumeTrue("Uses Windows-specific features", Functions.isWindows());
315316
File targetDir = tmp.newFolder();
316317
File file = new File(targetDir, "test-file");
317318
new FilePath(file).touch(System.currentTimeMillis());
@@ -325,6 +326,7 @@ public void testIsSymlink_ParentIsJunction() throws IOException, InterruptedExce
325326
@Test
326327
@Issue("JENKINS-55448")
327328
public void testIsSymlink_ParentIsSymlink() throws IOException, InterruptedException {
329+
assumeFalse(Functions.isWindows());
328330
File folder = tmp.newFolder();
329331
File file = new File(folder, "test-file");
330332
new FilePath(file).touch(System.currentTimeMillis());
@@ -592,6 +594,7 @@ private Date parseDate(String dateString) throws ParseException {
592594
@Test
593595
@Issue("SECURITY-904")
594596
public void resolveSymlinkToFile() throws Exception {
597+
assumeFalse(Functions.isWindows());
595598
// root
596599
// /a
597600
// /aa

core/src/test/java/hudson/util/AtomicFileWriterTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import static org.junit.Assert.assertFalse;
99
import static org.junit.Assert.assertThrows;
1010
import static org.junit.Assert.assertTrue;
11+
import static org.junit.Assume.assumeFalse;
1112
import static org.junit.Assume.assumeThat;
1213

1314
import edu.umd.cs.findbugs.annotations.Nullable;
15+
import hudson.Functions;
1416
import java.io.File;
1517
import java.io.IOException;
1618
import java.nio.charset.Charset;
@@ -73,6 +75,7 @@ public void setUp() throws IOException {
7375

7476
@Test
7577
public void symlinkToDirectory() throws Exception {
78+
assumeFalse(Functions.isWindows());
7679
final File folder = tmp.newFolder();
7780
final File containingSymlink = tmp.newFolder();
7881
final Path zeSymlink = Files.createSymbolicLink(Paths.get(containingSymlink.getAbsolutePath(), "ze_symlink"),

core/src/test/java/hudson/util/io/TarArchiverTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package hudson.util.io;
2525

2626
import static org.junit.Assert.assertEquals;
27-
import static org.junit.Assume.assumeTrue;
2827

2928
import hudson.FilePath;
3029
import hudson.Functions;
@@ -53,7 +52,7 @@ public class TarArchiverTest {
5352
*/
5453
@Issue("JENKINS-9397")
5554
@Test public void permission() throws Exception {
56-
assumeTrue(!Functions.isWindows());
55+
assumeFalse(Functions.isWindows());
5756

5857
File tar = File.createTempFile("test","tar");
5958
File zip = File.createTempFile("test","zip");
@@ -113,7 +112,7 @@ private static void run(FilePath dir, String... cmds) throws InterruptedExceptio
113112

114113
@Issue("JENKINS-14922")
115114
@Test public void brokenSymlinks() throws Exception {
116-
assumeTrue(!Functions.isWindows());
115+
assumeFalse(Functions.isWindows());
117116
File dir = tmp.getRoot();
118117
Util.createSymlink(dir, "nonexistent", "link", TaskListener.NULL);
119118
new FilePath(dir).tar(new NullStream(), "**");

core/src/test/java/jenkins/util/VirtualFileTest.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class VirtualFileTest {
8484

8585
@Issue("SECURITY-162")
8686
@Test public void outsideSymlinks() throws Exception {
87-
assumeFalse("Symlinks don't work well on Windows", Functions.isWindows());
87+
assumeFalse(Functions.isWindows());
8888
File ws = tmp.newFolder("ws");
8989
FileUtils.write(new File(ws, "safe"), "safe", StandardCharsets.US_ASCII, false);
9090
Util.createSymlink(ws, "safe", "supported", TaskListener.NULL);
@@ -231,6 +231,7 @@ public void list_Glob_NoFollowLinks_FileVF() throws Exception {
231231
@Test
232232
@Issue("SECURITY-1452")
233233
public void list_Glob_NoFollowLinks_FilePathVF() throws Exception {
234+
assumeFalse(Functions.isWindows());
234235
prepareFileStructureForIsDescendant(tmp.getRoot());
235236

236237
File root = tmp.getRoot();
@@ -361,7 +362,7 @@ public void zip_NoFollowLinks_FileVF_withPrefix() throws Exception {
361362

362363
@Issue("JENKINS-26810")
363364
@Test public void readLink() throws Exception {
364-
assumeFalse("Symlinks do not work well on Windows", Functions.isWindows());
365+
assumeFalse(Functions.isWindows());
365366
File root = tmp.getRoot();
366367
FilePath rootF = new FilePath(root);
367368
rootF.child("plain").write("", null);
@@ -424,6 +425,7 @@ public void list_NoFollowLinks_FilePathVF() throws Exception {
424425
@Test
425426
@Issue("SECURITY-1452")
426427
public void simpleList_WithSymlink_FileVF() throws Exception {
428+
assumeFalse(Functions.isWindows());
427429
prepareFileStructureForIsDescendant(tmp.getRoot());
428430

429431
File root = tmp.getRoot();
@@ -441,6 +443,7 @@ public void simpleList_WithSymlink_FileVF() throws Exception {
441443
@Test
442444
@Issue("SECURITY-1452")
443445
public void list_NoFollowLinks_ExternalSymlink_FileVF() throws Exception {
446+
assumeFalse(Functions.isWindows());
444447
prepareFileStructureForIsDescendant(tmp.getRoot());
445448
File root = tmp.getRoot();
446449
String symlinkName = "symlink";
@@ -457,6 +460,7 @@ public void list_NoFollowLinks_ExternalSymlink_FileVF() throws Exception {
457460
@Test
458461
@Issue("SECURITY-1452")
459462
public void list_NoFollowLinks_ExternalSymlink_FilePathVF() throws Exception {
463+
assumeFalse(Functions.isWindows());
460464
prepareFileStructureForIsDescendant(tmp.getRoot());
461465
File root = tmp.getRoot();
462466
String symlinkName = "symlink";
@@ -473,6 +477,7 @@ public void list_NoFollowLinks_ExternalSymlink_FilePathVF() throws Exception {
473477
@Test
474478
@Issue("SECURITY-1452")
475479
public void list_Glob_NoFollowLinks_ExternalSymlink_FilePathVF() throws Exception {
480+
assumeFalse(Functions.isWindows());
476481
prepareFileStructureForIsDescendant(tmp.getRoot());
477482
File root = tmp.getRoot();
478483
String symlinkName = "symlink";
@@ -489,6 +494,7 @@ public void list_Glob_NoFollowLinks_ExternalSymlink_FilePathVF() throws Exceptio
489494
@Test
490495
@Issue("SECURITY-1452")
491496
public void list_Glob_NoFollowLinks_ExternalSymlink_FileVF() throws Exception {
497+
assumeFalse(Functions.isWindows());
492498
prepareFileStructureForIsDescendant(tmp.getRoot());
493499
File root = tmp.getRoot();
494500
String symlinkName = "symlink";
@@ -610,6 +616,7 @@ public void simpleList_FilePathVF() throws Exception {
610616
@Test
611617
@Issue("SECURITY-1452")
612618
public void simpleList_WithSymlink_FilePathVF() throws Exception {
619+
assumeFalse(Functions.isWindows());
613620
prepareFileStructureForIsDescendant(tmp.getRoot());
614621

615622
File root = tmp.getRoot();
@@ -669,6 +676,7 @@ public void list_NoFollowLinks_AbstractBase() throws Exception {
669676
@Test
670677
@Issue("SECURITY-1452")
671678
public void simpleList_WithSymlink_AbstractBase() throws Exception {
679+
assumeFalse(Functions.isWindows());
672680
// This test checks the method's behavior in the abstract base class,
673681
// which has limited behavior.
674682
prepareFileStructureForIsDescendant(tmp.getRoot());
@@ -688,6 +696,7 @@ public void simpleList_WithSymlink_AbstractBase() throws Exception {
688696
@Test
689697
@Issue("SECURITY-1452")
690698
public void list_NoFollowLinks_WithSymlink_AbstractBase() throws Exception {
699+
assumeFalse(Functions.isWindows());
691700
// This test checks the method's behavior in the abstract base class,
692701
// which generally does nothing.
693702
prepareFileStructureForIsDescendant(tmp.getRoot());
@@ -763,6 +772,7 @@ private void prepareFileStructureForIsDescendant(File root) throws Exception {
763772

764773
@Issue("SECURITY-904")
765774
@Test public void forFile_isDescendant() throws Exception {
775+
assumeFalse(Functions.isWindows());
766776
this.prepareFileStructureForIsDescendant(tmp.getRoot());
767777

768778
File root = tmp.getRoot();
@@ -779,6 +789,7 @@ private void prepareFileStructureForIsDescendant(File root) throws Exception {
779789
@Test
780790
@Issue("SECURITY-904")
781791
public void forFilePath_isDescendant() throws Exception {
792+
assumeFalse(Functions.isWindows());
782793
this.prepareFileStructureForIsDescendant(tmp.getRoot());
783794

784795
File root = tmp.getRoot();
@@ -851,6 +862,7 @@ private void checkCommonAssertionForIsDescendant(VirtualFile virtualRoot, Virtua
851862
@Test
852863
@Issue("JENKINS-55050")
853864
public void forFile_listOnlyDescendants_withoutIllegal() throws Exception {
865+
assumeFalse(Functions.isWindows());
854866
this.prepareFileStructureForIsDescendant(tmp.getRoot());
855867

856868
File root = tmp.getRoot();
@@ -866,6 +878,7 @@ public void forFile_listOnlyDescendants_withoutIllegal() throws Exception {
866878
@Test
867879
@Issue("SECURITY-904")
868880
public void forFilePath_listOnlyDescendants_withoutIllegal() throws Exception {
881+
assumeFalse(Functions.isWindows());
869882
this.prepareFileStructureForIsDescendant(tmp.getRoot());
870883

871884
File root = tmp.getRoot();
@@ -1101,6 +1114,7 @@ public void testOpenNoFollowLinks_AbstractBase() throws Exception {
11011114
@Test
11021115
@Issue("SECURITY-1452")
11031116
public void testOpenNoFollowLinks_FollowsLink_AbstractBase() throws Exception {
1117+
assumeFalse(Functions.isWindows());
11041118
// This test checks the method's behavior in the abstract base class,
11051119
// which generally does nothing.
11061120
File ws = tmp.newFolder("ws");
@@ -1423,6 +1437,7 @@ public void hasSymlink_False_FilePathVF() throws IOException {
14231437

14241438
@Test
14251439
public void hasSymlink_True_FilePathVF() throws IOException, InterruptedException {
1440+
assumeFalse(Functions.isWindows());
14261441
FilePath rootPath = new FilePath(tmp.getRoot());
14271442
FilePath childPath = rootPath.child("child");
14281443
childPath.touch(0);
@@ -1440,6 +1455,7 @@ public void hasSymlink_False_FileVF() throws IOException {
14401455

14411456
@Test
14421457
public void hasSymlink_True_FileVF() throws IOException, InterruptedException {
1458+
assumeFalse(Functions.isWindows());
14431459
FilePath rootPath = new FilePath(tmp.getRoot());
14441460
FilePath childPath = rootPath.child("child");
14451461
childPath.touch(0);

0 commit comments

Comments
 (0)