Skip to content

Commit

Permalink
[JENKINS-21905] Skip unittest on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergondza committed Sep 24, 2017
1 parent 9bd9c48 commit efbdac0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
Expand Up @@ -42,7 +42,9 @@
import java.util.Collections;
import java.util.List;

import hudson.remoting.VirtualChannel;
import hudson.slaves.DumbSlave;
import jenkins.MasterToSlaveFileCallable;
import jenkins.util.VirtualFile;
import org.hamcrest.Matchers;
import org.jenkinsci.plugins.structs.describable.DescribableModel;
Expand Down Expand Up @@ -290,11 +292,20 @@ public void testDefaultExcludesOff() throws Exception {

@Test @Issue("JENKINS-21905")
public void archiveNotReadable() throws Exception {
String FILENAME = "myfile";
assumeFalse(Functions.isWindows()); // No permission support

final String FILENAME = "myfile";
DumbSlave slave = j.createOnlineSlave(Label.get("target"));

FreeStyleProject p = j.createFreeStyleProject();
p.getBuildersList().add(new Shell("touch "+FILENAME+"; chmod 040 "+FILENAME+"; ls -l"));
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath file = build.getWorkspace().child(FILENAME);
file.act(new RemoveReadPermission());
return true;
}
});
p.getPublishersList().add(new ArtifactArchiver(FILENAME));
p.setAssignedNode(slave);

Expand All @@ -304,4 +315,13 @@ public void archiveNotReadable() throws Exception {
j.assertLogContains("ERROR: Step ‘Archive the artifacts’ failed: java.nio.file.AccessDeniedException: " + expectedPath, build);
assertThat("No stacktrace shown", build.getLog(31), Matchers.iterableWithSize(lessThan(30)));
}

private static class RemoveReadPermission extends MasterToSlaveFileCallable<Object> {
@Override
public Object invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
assertTrue(f.createNewFile());
assertTrue(f.setReadable(false));
return null;
}
}
}

0 comments on commit efbdac0

Please sign in to comment.