Made AbstractVcsTestCase.verify() public.
option.setValue(value);
}
- protected static void verify(final ProcessOutput runResult) {
+ public static void verify(final ProcessOutput runResult) {
Assert.assertEquals(runResult.getStderr(), 0, runResult.getExitCode());
}
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.AbstractVcsTestCase;
-import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
-import com.intellij.testFramework.fixtures.TempDirTestFixture;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.Nullable;
import org.testng.annotations.BeforeMethod;
myTraceClient = true;
}
- /**
- * Creates a new Mercurial repository in a temporary test directory.
- * @return created repository
- */
- protected HgTestRepository createRepository() throws Exception {
- final TempDirTestFixture dirFixture = createFixtureDir();
- final File repo = new File(dirFixture.getTempDirPath());
- ProcessOutput processOutput = runHg(repo, "init");
- verify(processOutput);
- return new HgTestRepository(this, dirFixture);
- }
-
- protected static TempDirTestFixture createFixtureDir() throws Exception {
- final TempDirTestFixture fixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
- fixture.setUp();
- return fixture;
- }
-
protected void enableSilentOperation(final VcsConfiguration.StandardConfirmation op) {
setStandardConfirmation(HgVcs.VCS_NAME, op, VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY);
}
*/
package org.zmlx.hg4idea.test;
-import com.intellij.execution.process.ProcessOutput;
import com.intellij.openapi.vcs.VcsConfiguration;
-import com.intellij.testFramework.fixtures.TempDirTestFixture;
import org.testng.annotations.BeforeMethod;
import org.zmlx.hg4idea.HgVcs;
protected void setUp() throws Exception {
super.setUp();
- myParentRepo = createRepository();
- myRepo = cloneFrom(myParentRepo);
+ myParentRepo = HgTestRepository.create(this);
+ myRepo = myParentRepo.cloneRepository();
myProjectDir = new File(myRepo.getDirFixture().getTempDirPath());
enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);
}
- /**
- * Clones a repository from the given one. New repository is located in a temporary test directory.
- * @param parent repository to clone from.
- * @return New repository cloned from the given parent.
- */
- protected HgTestRepository cloneFrom(HgTestRepository parent) throws Exception {
- final TempDirTestFixture dirFixture = createFixtureDir();
- final ProcessOutput processOutput = runHg(null, "clone", parent.getDirFixture().getTempDirPath(), dirFixture.getTempDirPath());
- verify(processOutput);
- return new HgTestRepository(this, dirFixture);
- }
-
}
protected void setUp() throws Exception {
super.setUp();
- myRepo = createRepository();
+ myRepo = HgTestRepository.create(this);
myProjectDir = new File(myRepo.getDirFixture().getTempDirPath());
initProject(myProjectDir);
*/
package org.zmlx.hg4idea.test;
+import com.intellij.execution.process.ProcessOutput;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.AbstractVcsTestCase;
+import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import com.intellij.testFramework.fixtures.TempDirTestFixture;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
myParent = parent;
}
+ /**
+ * Creates a new Mercurial repository in a new temporary test directory.
+ * @param testCase reference to the test case instance.
+ * @return created repository.
+ */
+ public static HgTestRepository create(HgAbstractTestCase testCase) throws Exception {
+ final TempDirTestFixture dirFixture = createFixtureDir();
+ final File repo = new File(dirFixture.getTempDirPath());
+ final ProcessOutput processOutput = testCase.runHg(repo, "init");
+ AbstractVcsTestCase.verify(processOutput);
+ return new HgTestRepository(testCase, dirFixture);
+ }
+
+ private static TempDirTestFixture createFixtureDir() throws Exception {
+ final TempDirTestFixture fixture = IdeaTestFixtureFactory.getFixtureFactory().createTempDirTestFixture();
+ fixture.setUp();
+ return fixture;
+ }
+
+ /**
+ * Clones a repository from this one. New repository is located in a new temporary test directory.
+ * @return New repository cloned from this one.
+ */
+ HgTestRepository cloneRepository() throws Exception {
+ final TempDirTestFixture dirFixture = createFixtureDir();
+ final ProcessOutput processOutput = myTest.runHg(null, "clone", getDirFixture().getTempDirPath(), dirFixture.getTempDirPath());
+ AbstractVcsTestCase.verify(processOutput);
+ return new HgTestRepository(myTest, dirFixture);
+ }
+
@NotNull
TempDirTestFixture getDirFixture() {
return myDirFixture;
}
+ public VirtualFile getDir() {
+ return myDirFixture.getFile(".");
+ }
+
+ public VirtualFile createFile(String filename) {
+ return myDirFixture.createFile(filename);
+ }
+
/**
* Natively executes the given mercurial command.
* @param commandWithParameters Mercurial command with parameters. E.g. ["status", "-a"]
execute("commit", "-m", "Sample commit message");
}
- void update() throws IOException {
- execute("update");
+ void merge() throws IOException {
+ execute("merge");
+ }
+
+ void pull() throws IOException {
+ execute("pull");
}
void push() throws IOException {
execute("push");
}
- public VirtualFile getDir() {
- return myDirFixture.getFile(".");
+ void update() throws IOException {
+ execute("update");
}
+
}