Skip to content
Permalink
Browse files
JENKINS-32039 "screen" default does not work
  • Loading branch information
zregvart committed Mar 20, 2016
1 parent 9b47232 commit fa47c05ced717109fc645f7dc7dd3b7bfc4522c7
Showing with 37 additions and 1 deletion.
  1. +5 −1 src/main/java/org/jenkinsci/plugins/xvfb/Xvfb.java
  2. +32 −0 src/test/java/org/jenkinsci/plugins/xvfb/XvfbBuildWrapperTest.java
@@ -441,7 +441,11 @@ protected ArgumentListBuilder createCommandArguments(final XvfbInstallation inst
cmd.add(":" + displayNameUsed);
}

cmd.add("-screen").add("0").add(screen).add("-fbdir").add(frameBufferDir);
if (screen != null && !screen.trim().isEmpty()) {
cmd.add("-screen").add("0").add(screen);
}

cmd.add("-fbdir").add(frameBufferDir);

if (additionalOptions != null) {
cmd.addTokenized(additionalOptions);
@@ -219,6 +219,38 @@ public void shouldCreateCommandLineArguments() throws IOException {
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();

0 comments on commit fa47c05

Please sign in to comment.