Skip to content

Commit

Permalink
[JENKINS-15829] Verified fix with test (see #50).
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Feb 12, 2014
1 parent 10b20d7 commit 36ac77a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/test/java/hudson/plugins/mercurial/SCMTestBase.java
Expand Up @@ -51,6 +51,15 @@ public abstract class SCMTestBase {

protected abstract String hgInstallation();

protected void assertClone(String log, boolean cloneExpected) {
if (cloneExpected) {
assertTrue(log, log.contains(" clone --"));
} else {
assertTrue(log, log.contains(" update --"));
assertFalse(log, log.contains(" clone --"));
}
}

@Bug(13329)
@Test public void basicOps() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
Expand All @@ -60,11 +69,25 @@ public abstract class SCMTestBase {
m.hg(repo, "init");
m.touchAndCommit(repo, "a");
String log = m.buildAndCheck(p, "a");
assertTrue(log, log.contains(" clone --"));
assertClone(log, true);
m.touchAndCommit(repo, "b");
log = m.buildAndCheck(p, "b");
assertClone(log, false);
}

@Bug(15829)
@Test public void basicOpsSlave() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
p.setScm(new MercurialSCM(hgInstallation(), repo.getPath(), null, null,
null, null, false));
p.setAssignedNode(j.createOnlineSlave());
m.hg(repo, "init");
m.touchAndCommit(repo, "a");
String log = m.buildAndCheck(p, "a");
assertClone(log, true);
m.touchAndCommit(repo, "b");
log = m.buildAndCheck(p, "b");
assertTrue(log, log.contains(" update --"));
assertFalse(log, log.contains(" clone --"));
assertClone(log, false);
}

@Bug(4281)
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/hudson/plugins/mercurial/SharingSCMTest.java
Expand Up @@ -3,6 +3,7 @@
import hudson.tools.ToolProperty;

import java.util.Collections;
import static org.junit.Assert.*;
import org.junit.Before;

public class SharingSCMTest extends SCMTestBase {
Expand All @@ -24,4 +25,13 @@ public class SharingSCMTest extends SCMTestBase {
return SHARING_INSTALLATION;
}

@Override protected void assertClone(String log, boolean cloneExpected) {
if (cloneExpected) {
assertTrue(log, log.contains(" share --"));
} else {
assertTrue(log, log.contains(" update --"));
assertFalse(log, log.contains(" share --"));
}
}

}

1 comment on commit 36ac77a

@blt04
Copy link
Contributor

@blt04 blt04 commented on 36ac77a Feb 13, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please sign in to comment.