Skip to content

Commit

Permalink
JENKINS-33288 Xvfb error does not fail build
Browse files Browse the repository at this point in the history
  • Loading branch information
zregvart committed Mar 20, 2016
1 parent 050a80c commit 5915aae
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jenkinsci/plugins/xvfb/Xvfb.java
Expand Up @@ -565,7 +565,7 @@ private XvfbEnvironment launchXvfb(final Run<?, ?> run, final FilePath workspace
if (installation == null) {
listener.error(Messages.XvfbBuildWrapper_NoInstallationsConfigured());

throw new InterruptedException();
throw new RunnerAbortedException();
}

final ArgumentListBuilder cmd = createCommandArguments(installation, frameBufferDir, displayNameUsed);
Expand Down
108 changes: 54 additions & 54 deletions src/test/java/org/jenkinsci/plugins/xvfb/XvfbBuildWrapperTest.java
Expand Up @@ -142,20 +142,66 @@ public void setupXvfbInstallations() throws IOException {
setupXvfbInstallations(system.jenkins, tempDir);
}

@Test
public void shouldCreateCommandLineArguments() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-screen", "0", Xvfb.DEFAULT_SCREEN, "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfEmpty() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen("");

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfNotGiven() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen(null);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@SuppressWarnings("unchecked")
@Test
public void shouldAbortIfInstallationIsNotFound() throws Exception {
public void shouldFailIfInstallationIsNotFound() throws Exception {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("nonexistant");

final FreeStyleProject project = createFreeStyleJob(system, "shouldAbortIfInstallationIsNotFound");
final FreeStyleProject project = createFreeStyleJob(system, "shouldFailIfInstallationIsNotFound");
setupXvfbOn(project, xvfb);

final QueueTaskFuture<FreeStyleBuild> buildResult = project.scheduleBuild2(0);

final FreeStyleBuild build = buildResult.get();

system.assertBuildStatus(Result.ABORTED, build);
system.assertBuildStatus(Result.FAILURE, build);

final List<String> logLines = build.getLog(10);

Expand All @@ -164,17 +210,17 @@ public void shouldAbortIfInstallationIsNotFound() throws Exception {

@SuppressWarnings("unchecked")
@Test
public void shouldAbortIfNoInstallationIsDefined() throws Exception {
public void shouldFailIfNoInstallationIsDefined() throws Exception {
final Xvfb xvfb = new Xvfb();

final FreeStyleProject project = createFreeStyleJob(system, "shouldAbortIfNoInstallationIsDefined");
final FreeStyleProject project = createFreeStyleJob(system, "shouldFailIfNoInstallationIsDefined");
setupXvfbOn(project, xvfb);

final QueueTaskFuture<FreeStyleBuild> buildResult = project.scheduleBuild2(0);

final FreeStyleBuild build = buildResult.get();

system.assertBuildStatus(Result.ABORTED, build);
system.assertBuildStatus(Result.FAILURE, build);

final List<String> logLines = build.getLog(10);

Expand All @@ -184,12 +230,12 @@ public void shouldAbortIfNoInstallationIsDefined() throws Exception {
@SuppressWarnings("unchecked")
@Test
@Issue("JENKINS-18094")
public void shouldAbortIfXvfbFailsToStart() throws Exception {
public void shouldFailIfXvfbFailsToStart() throws Exception {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("failing");
xvfb.setTimeout(10);

final FreeStyleProject project = createFreeStyleJob(system, "shouldAbortIfXvfbFailsToStart");
final FreeStyleProject project = createFreeStyleJob(system, "shouldFailIfXvfbFailsToStart");
setupXvfbOn(project, xvfb);

final QueueTaskFuture<FreeStyleBuild> buildResult = project.scheduleBuild2(0);
Expand All @@ -205,52 +251,6 @@ public void shouldAbortIfXvfbFailsToStart() throws Exception {

}

@Test
public void shouldCreateCommandLineArguments() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-screen", "0", Xvfb.DEFAULT_SCREEN, "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfNotGiven() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen(null);

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
@Issue("JENKINS-32039")
public void shouldCreateCommandLineArgumentsWithoutScreenIfEmpty() throws IOException {
final Xvfb xvfb = new Xvfb();
xvfb.setInstallationName("cmd");
xvfb.setDisplayName(42);
xvfb.setScreen("");

final XvfbInstallation installation = new XvfbInstallation("cmd", "/usr/local/cmd-xvfb", null);

final File tempDirRoot = tempDir.getRoot();
final ArgumentListBuilder arguments = xvfb.createCommandArguments(installation, new FilePath(tempDirRoot), 42);

assertThat(arguments.toList(), contains("/usr/local/cmd-xvfb/Xvfb", ":42", "-fbdir", tempDirRoot.getAbsolutePath()));
}

@Test
public void shouldHonourSpecifiedDisplayNameOffset() throws Exception {
final Xvfb xvfb = new Xvfb();
Expand Down

0 comments on commit 5915aae

Please sign in to comment.