private List<GitRepository> myRepositories;
public void setUp() throws Exception {
- try {
- super.setUp();
- }
- catch (Throwable t) {
- super.tearDown();
- }
+ super.setUp();
- try {
- cd(myProjectRoot);
- File community = mkdir("community");
- File contrib = mkdir("contrib");
+ cd(myProjectRoot);
+ File community = mkdir("community");
+ File contrib = mkdir("contrib");
- myUltimate = createRepository(myProjectPath);
- myCommunity = createRepository(community.getPath());
- myContrib = createRepository(contrib.getPath());
- myRepositories = Arrays.asList(myUltimate, myCommunity, myContrib);
+ myUltimate = createRepository(myProjectPath);
+ myCommunity = createRepository(community.getPath());
+ myContrib = createRepository(contrib.getPath());
+ myRepositories = Arrays.asList(myUltimate, myCommunity, myContrib);
- cd(myProjectRoot);
- touch(".gitignore", "community\ncontrib");
- git("add .gitignore");
- git("commit -m gitignore");
- }
- catch (Exception e) {
- tearDown();
- throw e;
- }
+ cd(myProjectRoot);
+ touch(".gitignore", "community\ncontrib");
+ git("add .gitignore");
+ git("commit -m gitignore");
}
public void test_create_new_branch_without_problems() {
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.VcsTestUtil;
import com.intellij.util.Function;
+import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.io.ZipUtil;
-import com.intellij.util.ui.UIUtil;
import com.intellij.vcs.log.Hash;
import com.intellij.vcs.log.impl.HashImpl;
import git4idea.GitBranch;
});
}
- @SuppressWarnings({"UnusedParameters"})
+ @SuppressWarnings({"UnusedParameters", "JUnitTestCaseWithNonTrivialConstructors"})
public GitRepositoryReaderTest(@NotNull String name, @NotNull File testDir) {
myTestCaseDir = testDir;
}
@Override
@Before
public void setUp() throws Exception {
- super.setUp();
+ edt(new ThrowableRunnable() {
+ @Override
+ public void run() throws Exception {
+ GitRepositoryReaderTest.super.setUp();
+ }
+ });
myTempDir = new File(myProjectRoot.getPath(), "test");
prepareTest(myTestCaseDir);
}
@After
@Override
public void tearDown() throws Exception {
- FileUtil.delete(myTempDir);
- UIUtil.invokeAndWaitIfNeeded(new Runnable() {
- @Override
- public void run() {
- try {
+ try {
+ if (myTempDir != null) {
+ FileUtil.delete(myTempDir);
+ }
+ }
+ finally {
+ edt(new ThrowableRunnable() {
+ @Override
+ public void run() throws Throwable {
GitRepositoryReaderTest.super.tearDown();
}
- catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
+ });
+ }
}
private void prepareTest(File testDir) throws IOException {
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.TestLoggerFactory;
-import com.intellij.testFramework.UsefulTestCase;
-import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
-import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import com.intellij.testFramework.vcs.AbstractVcsTestCase;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ObjectUtils;
import java.util.*;
-public abstract class GitPlatformTest extends UsefulTestCase {
-
- static {
- Logger.setFactory(TestLoggerFactory.class);
- }
+public abstract class GitPlatformTest extends PlatformTestCase {
protected static final Logger LOG = Logger.getInstance(GitPlatformTest.class);
- protected Project myProject;
protected VirtualFile myProjectRoot;
protected String myProjectPath;
protected GitRepositoryManager myGitRepositoryManager;
protected TestDialogManager myDialogManager;
protected TestVcsNotifier myVcsNotifier;
- private IdeaProjectTestFixture myProjectFixture;
private String myTestStartedIndicator;
@Override
super.setUp();
enableDebugLogging();
- try {
- myProjectFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture();
- myProjectFixture.setUp();
- }
- catch (Exception e) {
- super.tearDown();
- throw e;
- }
-
- try {
- myProject = myProjectFixture.getProject();
- myProjectRoot = myProject.getBaseDir();
- myProjectPath = myProjectRoot.getPath();
+ myProjectRoot = myProject.getBaseDir();
+ myProjectPath = myProjectRoot.getPath();
- myGitSettings = GitVcsSettings.getInstance(myProject);
- myGitSettings.getAppSettings().setPathToGit(GitExecutor.PathHolder.GIT_EXECUTABLE);
+ myGitSettings = GitVcsSettings.getInstance(myProject);
+ myGitSettings.getAppSettings().setPathToGit(GitExecutor.PathHolder.GIT_EXECUTABLE);
- myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
- myVcsNotifier = (TestVcsNotifier)ServiceManager.getService(myProject, VcsNotifier.class);
+ myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
+ myVcsNotifier = (TestVcsNotifier)ServiceManager.getService(myProject, VcsNotifier.class);
- myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
- myPlatformFacade = ServiceManager.getService(myProject, GitPlatformFacade.class);
- myGit = ServiceManager.getService(myProject, Git.class);
- myVcs = ObjectUtils.assertNotNull(GitVcs.getInstance(myProject));
- myVcs.doActivate();
+ myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
+ myPlatformFacade = ServiceManager.getService(myProject, GitPlatformFacade.class);
+ myGit = ServiceManager.getService(myProject, Git.class);
+ myVcs = ObjectUtils.assertNotNull(GitVcs.getInstance(myProject));
+ myVcs.doActivate();
- GitTestUtil.assumeSupportedGitVersion(myVcs);
- addSilently();
- removeSilently();
- }
- catch (Exception e) {
- tearDown();
- throw e;
- }
+ GitTestUtil.assumeSupportedGitVersion(myVcs);
+ addSilently();
+ removeSilently();
}
@Override
if (myVcsNotifier != null) {
myVcsNotifier.cleanup();
}
- if (myProjectFixture != null) {
- myProjectFixture.tearDown();
- }
}
finally {
try {
- String tempTestIndicator = myTestStartedIndicator;
- clearFields(this);
- myTestStartedIndicator = tempTestIndicator;
+ super.tearDown();
}
finally {
- super.tearDown();
+ if (myAssertionsInTestDetected) {
+ TestLoggerFactory.dumpLogToStdout(myTestStartedIndicator);
+ }
}
}
}
return Collections.emptyList();
}
- @Override
- protected void defaultRunBare() throws Throwable {
- try {
- super.defaultRunBare();
- }
- catch (Throwable throwable) {
- if (myTestStartedIndicator != null) {
- TestLoggerFactory.dumpLogToStdout(myTestStartedIndicator);
- }
- throw throwable;
- }
- }
-
@NotNull
private String createTestStartedIndicator() {
return "Starting " + getClass().getName() + "." + getTestName(false) + Math.random();