mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DRY: let HgPlatformTest extend VcsPlatformTest
This commit is contained in:
@@ -21,5 +21,6 @@
|
||||
<orderEntry type="module" module-name="vcs-log-impl" />
|
||||
<orderEntry type="module" module-name="dvcs-api" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="vcs-tests" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -21,9 +21,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.vcs.test.VcsPlatformTest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.HgVcs;
|
||||
@@ -47,58 +45,35 @@ import static hg4idea.test.HgExecutor.hg;
|
||||
* or create another one.</li>
|
||||
* <li>Initially one repository is created with the project dir as its root. I. e. all project is under Mercurial.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public abstract class HgPlatformTest extends UsefulTestCase {
|
||||
public abstract class HgPlatformTest extends VcsPlatformTest {
|
||||
|
||||
protected Project myProject;
|
||||
protected VirtualFile myRepository;
|
||||
protected VirtualFile myChildRepo;
|
||||
protected HgVcs myVcs;
|
||||
|
||||
protected static final String COMMIT_MESSAGE = "text";
|
||||
|
||||
private IdeaProjectTestFixture myProjectFixture;
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
try {
|
||||
myProjectFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture();
|
||||
myProjectFixture.setUp();
|
||||
}
|
||||
catch (Exception e) {
|
||||
super.tearDown();
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
myProject = myProjectFixture.getProject();
|
||||
VirtualFile projectRoot = myProject.getBaseDir();
|
||||
|
||||
cd(projectRoot);
|
||||
hg("version");
|
||||
cd(myProjectRoot);
|
||||
hg("version");
|
||||
|
||||
createRepository(projectRoot);
|
||||
myVcs = HgVcs.getInstance(myProject);
|
||||
assertNotNull(myVcs);
|
||||
myVcs.getGlobalSettings().setHgExecutable(HgExecutor.getHgExecutable());
|
||||
myVcs.checkVersion();
|
||||
myRepository = projectRoot;
|
||||
setUpHgrc(myRepository);
|
||||
}
|
||||
catch (Exception e) {
|
||||
tearDown();
|
||||
throw e;
|
||||
}
|
||||
createRepository(myProjectRoot);
|
||||
myVcs = HgVcs.getInstance(myProject);
|
||||
assertNotNull(myVcs);
|
||||
myVcs.getGlobalSettings().setHgExecutable(HgExecutor.getHgExecutable());
|
||||
myVcs.checkVersion();
|
||||
myRepository = myProjectRoot;
|
||||
setUpHgrc(myRepository);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
((ChangeListManagerImpl)ChangeListManager.getInstance(myProject)).waitEverythingDoneInTestMode();
|
||||
myProjectFixture.tearDown();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class HgAnnotationTest extends HgPlatformTest {
|
||||
static final String dName = "d.txt";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cd(myRepository);
|
||||
appendToHgrc(myRepository, "[extensions]\n" +
|
||||
|
||||
@@ -38,7 +38,7 @@ public class HgHistoryTest extends HgPlatformTest {
|
||||
static final String subDirName = "sub";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cd(myRepository);
|
||||
appendToHgrc(myRepository, "[extensions]\n" +
|
||||
|
||||
@@ -43,7 +43,7 @@ public class HgUserFilterTest extends HgPlatformTest {
|
||||
private VcsLogUserFilterTest myVcsLogUserFilterTest;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cd(myProject.getBaseDir());
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.merge.MergeData;
|
||||
import com.intellij.openapi.vcs.merge.MergeProvider;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.EdtTestUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import hg4idea.test.HgPlatformTest;
|
||||
import hg4idea.test.HgTestUtil;
|
||||
import org.testng.Assert;
|
||||
@@ -27,16 +29,14 @@ import org.zmlx.hg4idea.HgVcs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.intellij.openapi.vcs.Executor.cd;
|
||||
import static com.intellij.openapi.vcs.Executor.echo;
|
||||
import static com.intellij.openapi.vcs.Executor.touch;
|
||||
import static com.intellij.openapi.vcs.Executor.*;
|
||||
import static hg4idea.test.HgExecutor.*;
|
||||
|
||||
public class HgMergeProviderTest extends HgPlatformTest {
|
||||
protected MergeProvider myMergeProvider;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
HgVcs vcs = HgVcs.getInstance(myProject);
|
||||
@@ -185,10 +185,12 @@ public class HgMergeProviderTest extends HgPlatformTest {
|
||||
|
||||
private void verifyMergeData(final VirtualFile file, String expectedBase, String expectedLocal, String expectedServer)
|
||||
throws VcsException {
|
||||
final MergeData mergeData = myMergeProvider.loadRevisions(file);
|
||||
assertEquals(expectedBase, mergeData.ORIGINAL);
|
||||
assertEquals(expectedServer, mergeData.LAST);
|
||||
assertEquals(expectedLocal, mergeData.CURRENT);
|
||||
EdtTestUtil.runInEdtAndWait((ThrowableRunnable<Throwable>)() -> {
|
||||
MergeData mergeData = myMergeProvider.loadRevisions(file);
|
||||
assertEquals(expectedBase, mergeData.ORIGINAL);
|
||||
assertEquals(expectedServer, mergeData.LAST);
|
||||
assertEquals(expectedLocal, mergeData.CURRENT);
|
||||
});
|
||||
}
|
||||
|
||||
private static void assertEquals(String s, byte[] bytes) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import static hg4idea.test.HgExecutor.hgMergeWith;
|
||||
|
||||
public class HgRevertUncommittedMergeTest extends HgPlatformTest {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MqPatchTest extends HgPlatformTest {
|
||||
private VirtualFile myMqPatchDir;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cd(myRepository);
|
||||
appendToHgrc(myRepository, "[extensions]\n" +
|
||||
|
||||
@@ -22,5 +22,6 @@
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="git4idea" scope="TEST" />
|
||||
<orderEntry type="module" module-name="hg4idea" scope="TEST" />
|
||||
<orderEntry type="module" module-name="vcs-tests" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
Reference in New Issue
Block a user