Skip to content

Commit

Permalink
Merge pull request #91 from sschuberth/master
Browse files Browse the repository at this point in the history
Miscellaneous minor fixes and improvements
  • Loading branch information
svanoort committed Nov 5, 2015
2 parents e54b5c3 + 6e2daef commit 9741736
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ THE SOFTWARE.
<f:entry title="${%Projects to build}" field="projects">
<f:textbox />
</f:entry>
<!-- TODO: replace with <f:optionalProperty> -->
<f:optionalBlock field="block" title="${%Block until the triggered projects finish their builds}" checked="${instance.block!=null}">
<j:set var="descriptor" value="${app.getDescriptorOrDie(descriptor.getPropertyType(field).clazz)}" />
<j:set var="instance" value="${instance[field]}"/>
<st:include from="${descriptor}" page="${descriptor.configPage}" />
</f:optionalBlock>

<f:optionalProperty field="block" title="${%Block until the triggered projects finish their builds}" />
<f:block>
<f:hetero-list name="configs" hasHeader="true"
descriptors="${descriptor.getBuilderConfigDescriptors()}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.jvnet.hudson.test.TestBuilder;
import org.junit.Test;

import java.nio.charset.Charset;
import java.util.Collections;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -96,7 +97,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}
});

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP));

projectA.scheduleBuild2(0).get();
Expand Down Expand Up @@ -135,7 +136,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
return true;
}
});
// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP));

projectA.scheduleBuild2(0).get();
Expand Down Expand Up @@ -166,7 +167,7 @@ public void testNoFilesSkip() throws Exception {
//create triggering build
FreeStyleProject projectA = createFreeStyleProject();

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP));

projectA.scheduleBuild2(0).get();
Expand All @@ -188,7 +189,7 @@ public void testNoFilesNoParms() throws Exception {
//create triggering build
FreeStyleProject projectA = createFreeStyleProject();

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.NOPARMS));

projectA.scheduleBuild2(0).get();
Expand All @@ -210,7 +211,7 @@ public void testNoFilesFail() throws Exception {
//create triggering build
FreeStyleProject projectA = createFreeStyleProject();

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.FAIL));

projectA.scheduleBuild2(0).get();
Expand Down Expand Up @@ -242,7 +243,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}
});

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP, "UTF-8"));

projectA.scheduleBuild2(0).get();
Expand Down Expand Up @@ -285,7 +286,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}
});

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP, "Shift_JIS"));

projectA.scheduleBuild2(0).get();
Expand Down Expand Up @@ -323,7 +324,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
}
});

// add Trigger builder, with file paramter factory
// add Trigger builder, with file parameter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP, ""));

projectA.scheduleBuild2(0).get();
Expand All @@ -333,11 +334,15 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
List<FreeStyleBuild> builds = projectB.getBuilds();
assertEquals(1, builds.size());

for (FreeStyleBuild build : builds) {
EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
assertEquals("hello_abc", buildEnvVar.get("TEST"));
// This test explicitly uses the platform's default encoding, which e.g. on Windows is likely to be windows-1250
// or windows-1252. With these single-byte encodings we cannot expect multi-byte strings to be encoded correctly.
final boolean isMultiByteDefaultCharset = Charset.defaultCharset().newEncoder().maxBytesPerChar() > 1.0f;
if (isMultiByteDefaultCharset) {
for (FreeStyleBuild build : builds) {
EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
assertEquals("hello_abc", buildEnvVar.get("TEST"));
}
}

}

public void testDoCheckEncoding() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,14 @@ public void testPlatformDefaultEncodedFile() throws Exception {
hudson.getQueue().getItem(projectB).getFuture().get();

assertNotNull("builder should record environment", builder.getEnvVars());
assertEquals("こんにちは", builder.getEnvVars().get("KEY"));
assertEquals("value", builder.getEnvVars().get("KEY"));

// This test explicitly uses the platform's default encoding, which e.g. on Windows is likely to be windows-1250
// or windows-1252. With these single-byte encodings we cannot expect multi-byte strings to be encoded correctly.
final boolean isMultiByteDefaultCharset = Charset.defaultCharset().newEncoder().maxBytesPerChar() > 1.0f;
if (isMultiByteDefaultCharset) {
assertEquals("こんにちは", builder.getEnvVars().get("KEY"));
assertEquals("value", builder.getEnvVars().get("KEY"));
}
}

public void testDoCheckEncoding() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void testTriggerByAbortedBuild() throws Exception {
assertEquals(2, projectB.getLastBuild().getNumber());
}

public void testTriggerByAbortedByInturrupted() throws Exception {
public void testTriggerByAbortedByInterrupted() throws Exception {
FreeStyleProject projectA = createFreeStyleProject("projectA");
projectA.getBuildersList().add(new SleepBuilder(10000));
FreeStyleProject projectB = createFreeStyleProject("projectB");
Expand Down

0 comments on commit 9741736

Please sign in to comment.