# HG changeset patch # User Dmitry Neverov # Date 1285671650 -14400 # Node ID 5ff5ff61f7d4df65742a1e1e70006bb3dd913903 # Parent 2159ab641618acc1f6832c71a8d3285b0a9bab46 Extract Util class and method getHgPath(). Now tests can be ran using installed hg in the system. diff -r 2159ab641618 -r 5ff5ff61f7d4 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java Tue Sep 28 13:38:23 2010 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java Tue Sep 28 15:00:50 2010 +0400 @@ -52,21 +52,12 @@ protected VcsRootImpl createVcsRoot(@NotNull String repPath) throws IOException { VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME); - vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(getHgPath()).getAbsolutePath()); + vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(Util.getHgPath()).getAbsolutePath()); File repository = LocalRepositoryUtil.prepareRepository(repPath); vcsRoot.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath()); return vcsRoot; } - private String getHgPath() throws IOException { - String providedHg = System.getenv(Constants.HG_PATH_ENV); - if (providedHg != null) { - return providedHg; - } else { - return "mercurial-tests/testData/bin/hg.exe"; - } - } - protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException { VcsRootImpl vcsRoot = createVcsRoot(repPath); vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName); diff -r 2159ab641618 -r 5ff5ff61f7d4 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java Tue Sep 28 15:00:50 2010 +0400 @@ -0,0 +1,21 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import java.io.IOException; + +/** + * @author dmitry.neverov + */ +public final class Util { + + private Util() {} + + public static String getHgPath() throws IOException { + String providedHg = System.getenv(Constants.HG_PATH_ENV); + if (providedHg != null) { + return providedHg; + } else { + return "mercurial-tests/testData/bin/hg.exe"; + } + } + +} diff -r 2159ab641618 -r 5ff5ff61f7d4 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java Tue Sep 28 13:38:23 2010 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java Tue Sep 28 15:00:50 2010 +0400 @@ -17,8 +17,9 @@ import jetbrains.buildServer.BaseTestCase; import jetbrains.buildServer.TempFiles; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; import jetbrains.buildServer.buildTriggers.vcs.mercurial.LocalRepositoryUtil; -import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.Util; import jetbrains.buildServer.vcs.VcsException; import jetbrains.buildServer.vcs.VcsRoot; import jetbrains.buildServer.vcs.impl.VcsRootImpl; @@ -26,8 +27,8 @@ import java.io.File; import java.io.IOException; +import java.util.HashMap; import java.util.Map; -import java.util.HashMap; public class BaseCommandTestCase extends BaseTestCase { private String myRepository; @@ -58,7 +59,7 @@ vcsRootProps.put(Constants.REPOSITORY_PROP, repository.getAbsolutePath()); } - vcsRootProps.put(Constants.HG_COMMAND_PATH_PROP, "mercurial-tests/testData/bin/hg.exe"); + vcsRootProps.put(Constants.HG_COMMAND_PATH_PROP, Util.getHgPath()); if (myUsername != null) { vcsRootProps.put(Constants.USERNAME, myUsername); }