Mercurial > hg > mercurial
annotate mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java @ 116:1c7e94c0ad2f
Add ability to use mercurial installed on the system.
We bundle hg.exe for tests, but it doesn't work on linux. Add ability to set hg executable to use in our tests in the same way as it done in git-plugin
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Mon, 23 Aug 2010 16:18:54 +0400 |
parents | 6c1cff1f61cc |
children | 5ff5ff61f7d4 |
rev | line source |
---|---|
95 | 1 /* |
2 * Copyright 2000-2010 JetBrains s.r.o. | |
3 * | |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 * you may not use this file except in compliance with the License. | |
6 * You may obtain a copy of the License at | |
7 * | |
8 * http://www.apache.org/licenses/LICENSE-2.0 | |
9 * | |
10 * Unless required by applicable law or agreed to in writing, software | |
11 * distributed under the License is distributed on an "AS IS" BASIS, | |
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 * See the License for the specific language governing permissions and | |
14 * limitations under the License. | |
15 */ | |
34
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
16 package jetbrains.buildServer.buildTriggers.vcs.mercurial; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
17 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
18 import jetbrains.buildServer.MockSupport; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
19 import jetbrains.buildServer.TempFiles; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
20 import jetbrains.buildServer.vcs.impl.VcsRootImpl; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
21 import jetbrains.buildServer.vcs.patches.PatchTestCase; |
57 | 22 import org.jetbrains.annotations.NotNull; |
34
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
23 import org.testng.annotations.AfterMethod; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
24 import org.testng.annotations.BeforeMethod; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
25 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
26 import java.io.File; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
27 import java.io.IOException; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
28 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
29 /** |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
30 * @author Pavel.Sher |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
31 * Date: 31.07.2008 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
32 */ |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
33 public abstract class BaseMercurialTestCase extends PatchTestCase { |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
34 protected TempFiles myTempFiles; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
35 protected MockSupport myMockSupport; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
36 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
37 @Override |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
38 @BeforeMethod |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
39 protected void setUp() throws Exception { |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
40 super.setUp(); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
41 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
42 myMockSupport = new MockSupport(); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
43 myMockSupport.setUpMocks(); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
44 myTempFiles = new TempFiles(); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
45 } |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
46 |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
47 @AfterMethod |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
48 protected void tearDown() throws Exception { |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
49 myMockSupport.tearDownMocks(); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
50 myTempFiles.cleanup(); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
51 } |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
52 |
90 | 53 protected VcsRootImpl createVcsRoot(@NotNull String repPath) throws IOException { |
34
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
54 VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME); |
116
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
55 vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(getHgPath()).getAbsolutePath()); |
44 | 56 File repository = LocalRepositoryUtil.prepareRepository(repPath); |
34
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
57 vcsRoot.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath()); |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
58 return vcsRoot; |
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
59 } |
44 | 60 |
116
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
61 private String getHgPath() throws IOException { |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
62 String providedHg = System.getenv(Constants.HG_PATH_ENV); |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
63 if (providedHg != null) { |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
64 return providedHg; |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
65 } else { |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
66 return "mercurial-tests/testData/bin/hg.exe"; |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
67 } |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
68 } |
1c7e94c0ad2f
Add ability to use mercurial installed on the system.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents:
95
diff
changeset
|
69 |
90 | 70 protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException { |
71 VcsRootImpl vcsRoot = createVcsRoot(repPath); | |
57 | 72 vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName); |
73 return vcsRoot; | |
74 } | |
75 | |
90 | 76 protected void cleanRepositoryAfterTest(@NotNull String repPath) { |
77 LocalRepositoryUtil.forgetRepository(repPath); | |
44 | 78 } |
79 | |
90 | 80 protected String simpleRepo() { |
81 return new File("mercurial-tests/testData/rep1").getAbsolutePath(); | |
44 | 82 } |
34
0052d368c90c
initial working version of agent side checkout + some tests
Pavel.Sher
parents:
diff
changeset
|
83 } |