Permalink
Browse files

[JENKINS-20392] Add test for Recent-History-Bug in merge-jobs.

  • Loading branch information...
mlex authored and MarkEWaite committed Aug 1, 2014
1 parent f612429 commit 54094393c170c94d330b1ae52101922092b0abd2
Showing with 35 additions and 0 deletions.
  1. +35 −0 src/test/java/hudson/plugins/git/GitSCMTest.java
@@ -21,6 +21,7 @@
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import hudson.remoting.VirtualChannel;
import hudson.scm.ChangeLogSet;
import hudson.scm.PollingResult;
import hudson.slaves.DumbSlave;
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry;
@@ -877,6 +878,40 @@ public void testMerge() throws Exception {
assertFalse("scm polling should not detect any more changes after build", project.poll(listener).hasChanges());
}

@Bug(20392)
public void testMergeChangelog() throws Exception {
FreeStyleProject project = setupSimpleProject("master");

GitSCM scm = new GitSCM(
createRemoteRepositories(),
Collections.singletonList(new BranchSpec("*")),
false, Collections.<SubmoduleConfig>emptyList(),
null, null,
Collections.<GitSCMExtension>emptyList());
scm.getExtensions().add(new PreBuildMerge(new UserMergeOptions("origin", "integration", "default")));
project.setScm(scm);

// create initial commit and then run the build against it:
// Here the changelog is by default empty (because changelog for first commit is always empty
commit("commitFileBase", johnDoe, "Initial Commit");
testRepo.git.branch("integration");
build(project, Result.SUCCESS, "commitFileBase");

// Create second commit and run build
// Here the changelog should contain exactly this one new commit
testRepo.git.checkout("master", "topic2");
final String commitFile2 = "commitFile2";
String commitMessage = "Commit number 2";
commit(commitFile2, johnDoe, commitMessage);
final FreeStyleBuild build2 = build(project, Result.SUCCESS, commitFile2);

ChangeLogSet<? extends ChangeLogSet.Entry> changeLog = build2.getChangeSet();
assertEquals("Changelog should contain one item", 1, changeLog.getItems().length);

GitChangeSet singleChange = (GitChangeSet) changeLog.getItems()[0];
assertEquals("Changelog should contain commit number 2", commitMessage, singleChange.getComment().trim());
}

public void testMergeWithSlave() throws Exception {
FreeStyleProject project = setupSimpleProject("master");
project.setAssignedLabel(createSlave().getSelfLabel());

0 comments on commit 5409439

Please sign in to comment.