mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] simplify tests dir structure
This commit is contained in:
@@ -38,7 +38,7 @@ import cucumber.annotation.Order;
|
||||
import git4idea.commands.Git;
|
||||
import git4idea.commands.GitHttpAuthService;
|
||||
import git4idea.config.GitVcsSettings;
|
||||
import git4idea.remote.GitHttpAuthTestService;
|
||||
import git4idea.test.GitHttpAuthTestService;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.test.GitExecutor;
|
||||
import git4idea.test.GitTestUtil;
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<applicationService serviceInterface="git4idea.commands.GitHttpAuthService"
|
||||
serviceImplementation="git4idea.remote.GitHttpAuthTestService"
|
||||
serviceImplementation="git4idea.test.GitHttpAuthTestService"
|
||||
overrides="true" />
|
||||
<applicationService serviceInterface="git4idea.DialogManager"
|
||||
serviceImplementation="git4idea.test.TestDialogManager"
|
||||
+1
-2
@@ -13,12 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package git4idea.tests.rebase;
|
||||
package git4idea.rebase;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.commands.Git;
|
||||
import git4idea.rebase.GitRebaser;
|
||||
import git4idea.test.GitPlatformTest;
|
||||
import git4idea.test.GitTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package git4idea.remote;
|
||||
package git4idea.test;
|
||||
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
+6
-11
@@ -18,10 +18,7 @@ package git4idea.test;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.TestVcsNotifier;
|
||||
import com.intellij.openapi.vcs.VcsConfiguration;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vcs.VcsShowConfirmationOption;
|
||||
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;
|
||||
@@ -40,8 +37,6 @@ import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static git4idea.test.GitExecutor.*;
|
||||
|
||||
public abstract class GitPlatformTest extends UsefulTestCase {
|
||||
|
||||
@NotNull protected Project myProject;
|
||||
@@ -81,7 +76,7 @@ public abstract class GitPlatformTest extends UsefulTestCase {
|
||||
myProjectPath = myProjectRoot.getPath();
|
||||
|
||||
myGitSettings = GitVcsSettings.getInstance(myProject);
|
||||
myGitSettings.getAppSettings().setPathToGit(GIT_EXECUTABLE);
|
||||
myGitSettings.getAppSettings().setPathToGit(GitExecutor.GIT_EXECUTABLE);
|
||||
|
||||
myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
|
||||
myVcsNotifier = (TestVcsNotifier)ServiceManager.getService(myProject, VcsNotifier.class);
|
||||
@@ -123,10 +118,10 @@ public abstract class GitPlatformTest extends UsefulTestCase {
|
||||
protected void prepareRemoteRepo(@NotNull GitRepository source) {
|
||||
final String target = "parent.git";
|
||||
final String targetName = "origin";
|
||||
cd(myProjectRoot);
|
||||
git("clone --bare '%s' %s", source.getRoot().getPath(), target);
|
||||
cd(source);
|
||||
git("remote add %s '%s'", targetName, myProjectRoot + "/" + target);
|
||||
Executor.cd(myProjectRoot);
|
||||
GitExecutor.git("clone --bare '%s' %s", source.getRoot().getPath(), target);
|
||||
GitExecutor.cd(source);
|
||||
GitExecutor.git("remote add %s '%s'", targetName, myProjectRoot + "/" + target);
|
||||
}
|
||||
|
||||
protected void refresh() {
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
package git4idea.test
|
||||
|
||||
import git4idea.repo.GitRepository
|
||||
import static git4idea.test.GitExecutor.*;
|
||||
import static GitExecutor.*;
|
||||
/**
|
||||
* Create popular scenarios used in multiple tests, for example:
|
||||
* - create a branch and commit something there;
|
||||
+7
-6
@@ -21,6 +21,7 @@ import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.Executor;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import git4idea.GitCommit;
|
||||
@@ -81,8 +82,8 @@ public class GitTestImpl implements Git {
|
||||
@NotNull
|
||||
@Override
|
||||
public GitCommandResult config(@NotNull GitRepository repository, String... params) {
|
||||
cd(repository);
|
||||
String output = git("config " + join(params, " "));
|
||||
GitExecutor.cd(repository);
|
||||
String output = GitExecutor.git("config " + join(params, " "));
|
||||
int exitCode = output.trim().isEmpty() ? 1 : 0;
|
||||
return new GitCommandResult(!output.contains("fatal") && exitCode == 0, exitCode, Collections.<String>emptyList(),
|
||||
Arrays.asList(StringUtil.splitByLines(output)), null);
|
||||
@@ -98,14 +99,14 @@ public class GitTestImpl implements Git {
|
||||
@Override
|
||||
public GitCommandResult checkAttr(@NotNull final GitRepository repository, @NotNull Collection<String> attributes,
|
||||
@NotNull Collection<VirtualFile> files) {
|
||||
cd(repository);
|
||||
GitExecutor.cd(repository);
|
||||
Collection<String> relativePaths = Collections2.transform(files, new Function<VirtualFile, String>() {
|
||||
@Override
|
||||
public String apply(VirtualFile input) {
|
||||
return FileUtil.getRelativePath(repository.getRoot().getPath(), input.getPath(), '/');
|
||||
}
|
||||
});
|
||||
String output = git("check-attr %s -- %s", join(attributes, " "), join(relativePaths, " "));
|
||||
String output = GitExecutor.git("check-attr %s -- %s", join(attributes, " "), join(relativePaths, " "));
|
||||
return commandResult(output);
|
||||
}
|
||||
|
||||
@@ -293,8 +294,8 @@ public class GitTestImpl implements Git {
|
||||
}
|
||||
|
||||
private static GitCommandResult execute(String workingDir, String operation, GitLineHandlerListener... listeners) {
|
||||
cd(workingDir);
|
||||
String out = git(operation);
|
||||
Executor.cd(workingDir);
|
||||
String out = GitExecutor.git(operation);
|
||||
feedOutput(out, listeners);
|
||||
return commandResult(out);
|
||||
}
|
||||
+5
-5
@@ -85,18 +85,18 @@ public class GitTestUtil {
|
||||
|
||||
public static void initRepo(@NotNull String repoRoot, boolean makeInitialCommit) {
|
||||
cd(repoRoot);
|
||||
git("init");
|
||||
GitExecutor.git("init");
|
||||
setupUsername();
|
||||
if (makeInitialCommit) {
|
||||
touch("initial.txt");
|
||||
git("add initial.txt");
|
||||
git("commit -m initial");
|
||||
GitExecutor.git("add initial.txt");
|
||||
GitExecutor.git("commit -m initial");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupUsername() {
|
||||
git("config user.name '" + USER_NAME + "'");
|
||||
git("config user.email '" + USER_EMAIL + "'");
|
||||
GitExecutor.git("config user.name '" + USER_NAME + "'");
|
||||
GitExecutor.git("config user.email '" + USER_EMAIL + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>TestDialogManager instead of showing the dialog, gives the control to a {@link git4idea.test.TestDialogHandler} which can specify the dialog exit code
|
||||
* <p>TestDialogManager instead of showing the dialog, gives the control to a {@link TestDialogHandler} which can specify the dialog exit code
|
||||
* (thus simulation different user choices) or even change other elements in the dialog.</p>
|
||||
* <p>To use it a test should register the {@link TestDialogHandler} implementation. For example:
|
||||
* <pre><code>
|
||||
@@ -24,7 +24,7 @@ import com.intellij.testFramework.VfsTestUtil;
|
||||
import git4idea.commands.GitHttpAuthService;
|
||||
import git4idea.commands.GitHttpAuthenticator;
|
||||
import git4idea.config.GitConfigUtil;
|
||||
import git4idea.remote.GitHttpAuthTestService;
|
||||
import git4idea.test.GitHttpAuthTestService;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.test.GitExecutor;
|
||||
import git4idea.test.GitPlatformTest;
|
||||
|
||||
Reference in New Issue
Block a user