jenkinsci/mercurial-plugin — pull request #31 by ReneKroon (2012-12-14 20:02:02+00:00)
Title: FIX: JENKINS-15806 (check return code of hg pull)

Hello, this fixed my issues with issue 15806. I did not manage to write a unit test, as the Jenkins test framework was a bit overwhelming. I would be happy to see a working unit test for this. The test i came up with (But which always fails, even in OK situation) :+1:

@Bug(15806)
public void testPullReturnCode() throws Exception
{
File repo2 = createTmpDir();

hg(repo, "init");
touchAndCommit(repo, "init");
hg(repo, "tag", "init");

String s = repo.toString();
hg(repo2, "clone", repo.toString(), repo2.toString());

// delete repo 1
repo.delete();

// do sample build where pull should fail
FreeStyleProject p = createFreeStyleProject();
MercurialSCM a = new MercurialSCM(hgInstallation(), repo2.getPath(), null, null,
null, null, false);
p.setScm(a);

Future b = p.scheduleBuild2(0);
while(!b.isDone())
{
Thread.sleep(1000);
}

// unfortuneately this is not correct
assertEquals(Result.SUCCESS, b.get().getResult());

}