Skip to content

Commit 8a84adf

Browse files
authored
Merge pull request #502 from jglick/WorkflowRunTest.logRotationOnlyProcessesCompletedBuilds
Flaky `WorkflowRunTest.logRotationOnlyProcessesCompletedBuilds` on Windows
2 parents 8a6fadd + 6ce8e85 commit 8a84adf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunTest.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
package org.jenkinsci.plugins.workflow.job;
2626

2727
import static org.awaitility.Awaitility.await;
28-
import static org.hamcrest.collection.IsEmptyCollection.empty;
2928
import static org.hamcrest.MatcherAssert.assertThat;
3029
import static org.hamcrest.Matchers.containsString;
31-
import static org.hamcrest.Matchers.emptyArray;
30+
import static org.hamcrest.Matchers.empty;
3231
import static org.hamcrest.Matchers.equalTo;
3332
import static org.hamcrest.Matchers.is;
3433
import static org.hamcrest.Matchers.notNullValue;
@@ -48,6 +47,7 @@
4847
import hudson.AbortException;
4948
import hudson.Extension;
5049
import hudson.ExtensionList;
50+
import hudson.Functions;
5151
import hudson.XmlFile;
5252
import hudson.model.*;
5353
import hudson.model.listeners.RunListener;
@@ -99,6 +99,7 @@
9999
import org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty;
100100
import org.jenkinsci.plugins.workflow.support.actions.EnvironmentAction;
101101
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
102+
import static org.junit.Assume.assumeFalse;
102103
import org.junit.ClassRule;
103104
import org.junit.Ignore;
104105
import org.junit.Rule;
@@ -697,6 +698,7 @@ public void onInitialize(Run run) {
697698

698699
@Issue("JENKINS-73835")
699700
@Test public void logRotationOnlyProcessesCompletedBuilds() throws Throwable {
701+
assumeFalse("TODO #502: failing in VMs", Functions.isWindows() && "true".equals(System.getenv("CI")));
700702
logging.record(LogRotator.class, Level.FINER);
701703
var p = r.createProject(WorkflowJob.class);
702704
p.setDefinition(new CpsFlowDefinition(
@@ -725,11 +727,14 @@ public void onInitialize(Run run) {
725727
}
726728
LOGGER.info("Checking that all build directories are empty");
727729
for (int i = 0; i < buildsToRun; i++) {
728-
String[] filesInBuildDir = buildDirs[i].list();
729-
if (filesInBuildDir == null) {
730-
filesInBuildDir = new String[0];
731-
}
732-
assertThat("Expected " + buildDirs[i] + " to be empty but saw: " + Arrays.toString(filesInBuildDir), filesInBuildDir, emptyArray());
730+
var dir = buildDirs[i];
731+
await(dir + " should be empty").until(() -> {
732+
var filesInBuildDir = dir.list();
733+
if (filesInBuildDir == null) {
734+
filesInBuildDir = new String[0];
735+
}
736+
return Arrays.asList(filesInBuildDir);
737+
}, empty());
733738
}
734739
}
735740

0 commit comments

Comments
 (0)