mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git tests: move some merge helpers to the base class
Also rename the AbstractVcsHelper instance: drop the 'my' prefix alien to Kotlin
This commit is contained in:
@@ -20,7 +20,6 @@ import com.intellij.dvcs.push.PushSupport
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.openapi.util.Condition
|
||||
import com.intellij.openapi.util.Trinity
|
||||
import com.intellij.openapi.vcs.AbstractVcsHelper
|
||||
import com.intellij.openapi.vcs.Executor
|
||||
import com.intellij.util.ObjectUtils
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
@@ -41,14 +40,12 @@ import java.io.File
|
||||
abstract class GitPushOperationBaseTest : GitPlatformTest() {
|
||||
|
||||
protected lateinit var myPushSupport: GitPushSupport
|
||||
protected lateinit var myVcsHelper: MockVcsHelper
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
myPushSupport = findGitPushSupport()
|
||||
myVcsHelper = GitTestUtil.overrideService(myProject, AbstractVcsHelper::class.java, MockVcsHelper::class.java)
|
||||
}
|
||||
|
||||
override fun getDebugLogCategories() = super.getDebugLogCategories().plus("#" + GitPushOperation::class.java.name)
|
||||
|
||||
@@ -318,7 +318,7 @@ class GitPushOperationSingleRepoTest : GitPushOperationBaseTest() {
|
||||
makeCommit("msg")
|
||||
|
||||
agreeToUpdate(GitRejectedPushUpdateDialog.REBASE_EXIT_CODE)
|
||||
myVcsHelper.onMerge {}
|
||||
vcsHelper.onMerge {}
|
||||
|
||||
val result = push("master", "origin/master")
|
||||
assertResult(REJECTED_NO_FF, -1, "master", "origin/master", GitUpdateResult.INCOMPLETE, listOf("bro.txt"), result)
|
||||
|
||||
@@ -87,7 +87,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
var confirmation: String? = null
|
||||
myDialogManager.onMessage {
|
||||
confirmation = it
|
||||
Messages.YES;
|
||||
Messages.YES
|
||||
}
|
||||
|
||||
abortOngoingRebase()
|
||||
@@ -95,7 +95,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
assertNotNull(confirmation, "Abort confirmation message was not shown")
|
||||
assertEquals("Incorrect confirmation message text",
|
||||
cleanupForAssertion("Do you want to rollback the successful rebase in project?"),
|
||||
cleanupForAssertion(confirmation!!));
|
||||
cleanupForAssertion(confirmation!!))
|
||||
assertNoRebaseInProgress(myAllRepositories)
|
||||
myAllRepositories.forEach { it.`assert feature not rebased on master`() }
|
||||
|
||||
@@ -111,7 +111,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
var confirmation: String? = null
|
||||
myDialogManager.onMessage {
|
||||
confirmation = it
|
||||
Messages.YES;
|
||||
Messages.YES
|
||||
}
|
||||
|
||||
abortOngoingRebase()
|
||||
@@ -119,7 +119,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
assertNotNull(confirmation, "Abort confirmation message was not shown")
|
||||
assertEquals("Incorrect confirmation message text",
|
||||
cleanupForAssertion("Do you want just to abort rebase in community, or also rollback the successful rebase in project?"),
|
||||
cleanupForAssertion(confirmation!!));
|
||||
cleanupForAssertion(confirmation!!))
|
||||
assertNoRebaseInProgress(myAllRepositories)
|
||||
myAllRepositories.forEach { it.`assert feature not rebased on master`() }
|
||||
|
||||
@@ -133,7 +133,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
|
||||
var facedConflictInUltimate = false
|
||||
var facedConflictInCommunity = false
|
||||
myVcsHelper.onMerge({
|
||||
vcsHelper.onMerge({
|
||||
assertFalse(facedConflictInCommunity && facedConflictInUltimate)
|
||||
if (myUltimate.hasConflict("c.txt")) {
|
||||
assertFalse(facedConflictInUltimate)
|
||||
@@ -170,7 +170,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
assertNoRebaseInProgress(myAllRepositories)
|
||||
}
|
||||
|
||||
public fun `test continue rebase shouldn't attempt to stash`() {
|
||||
fun `test continue rebase shouldn't attempt to stash`() {
|
||||
myUltimate.`diverge feature and master`()
|
||||
myCommunity.`prepare simple conflict`()
|
||||
myContrib.`diverge feature and master`()
|
||||
@@ -183,7 +183,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
assertNotRebased("feature", "master", myCommunity)
|
||||
}
|
||||
|
||||
public fun `test continue rebase with unresolved conflicts should show merge dialog`() {
|
||||
fun `test continue rebase with unresolved conflicts should show merge dialog`() {
|
||||
myUltimate.`diverge feature and master`()
|
||||
myCommunity.`prepare simple conflict`()
|
||||
myContrib.`diverge feature and master`()
|
||||
@@ -192,7 +192,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
rebase("master")
|
||||
|
||||
var mergeDialogShown = false
|
||||
myVcsHelper.onMerge {
|
||||
vcsHelper.onMerge {
|
||||
mergeDialogShown = true
|
||||
resolveConflicts(myCommunity)
|
||||
}
|
||||
@@ -221,7 +221,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
var confirmation: String? = null
|
||||
myDialogManager.onMessage {
|
||||
confirmation = it
|
||||
Messages.YES;
|
||||
Messages.YES
|
||||
}
|
||||
|
||||
abortOngoingRebase()
|
||||
@@ -229,7 +229,7 @@ class GitMultiRepoRebaseTest : GitRebaseBaseTest() {
|
||||
assertNotNull(confirmation, "Abort confirmation message was not shown")
|
||||
assertEquals("Incorrect confirmation message text",
|
||||
cleanupForAssertion("Do you want to rollback the successful rebase in project?"),
|
||||
cleanupForAssertion(confirmation!!));
|
||||
cleanupForAssertion(confirmation!!))
|
||||
assertNoRebaseInProgress(myAllRepositories)
|
||||
myAllRepositories.forEach {
|
||||
it.`assert feature not rebased on master`()
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.dvcs.repo.Repository
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.AbstractVcsHelper
|
||||
import com.intellij.openapi.vcs.Executor
|
||||
import git4idea.GitUtil
|
||||
import git4idea.branch.GitRebaseParams
|
||||
@@ -32,14 +31,6 @@ abstract class GitRebaseBaseTest : GitPlatformTest() {
|
||||
|
||||
protected val LOCAL_CHANGES_WARNING : String = "Note that some local changes were <a>stashed</a> before rebase."
|
||||
|
||||
lateinit protected var myVcsHelper: MockVcsHelper
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
myVcsHelper = GitTestUtil.overrideService(myProject, AbstractVcsHelper::class.java, MockVcsHelper::class.java)
|
||||
}
|
||||
|
||||
override fun createRepository(rootDir: String) = GitTestUtil.createRepository(myProject, rootDir, false)
|
||||
|
||||
override fun getDebugLogCategories() = super.getDebugLogCategories().plus("#git4idea.rebase")
|
||||
@@ -116,7 +107,7 @@ abstract class GitRebaseBaseTest : GitPlatformTest() {
|
||||
}
|
||||
|
||||
protected fun GitRepository.`make rebase fail after resolving conflicts`() {
|
||||
myVcsHelper.onMerge {
|
||||
vcsHelper.onMerge {
|
||||
resolveConflicts(this)
|
||||
myGit.setShouldRebaseFail { true }
|
||||
}
|
||||
@@ -127,10 +118,6 @@ abstract class GitRebaseBaseTest : GitPlatformTest() {
|
||||
git("add -u .")
|
||||
}
|
||||
|
||||
protected fun `do nothing on merge`() {
|
||||
myVcsHelper.onMerge{}
|
||||
}
|
||||
|
||||
protected fun assertSuccessfulRebaseNotification(message: String) : Notification {
|
||||
return assertSuccessfulNotification("Rebase Successful", message)
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
|
||||
rebaseOnMaster()
|
||||
|
||||
assertTrue(myVcsHelper.mergeDialogWasShown())
|
||||
`assert merge dialog was shown`()
|
||||
}
|
||||
|
||||
fun `test fail on 2nd commit should show notification with proposal to abort`() {
|
||||
@@ -104,7 +104,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
}
|
||||
|
||||
var conflicts = 0
|
||||
myVcsHelper.onMerge {
|
||||
vcsHelper.onMerge {
|
||||
conflicts++
|
||||
myRepo.assertConflict("c.txt")
|
||||
resolveConflicts(myRepo)
|
||||
@@ -120,7 +120,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
fun `test continue rebase after resolving all conflicts`() {
|
||||
myRepo.`prepare simple conflict`()
|
||||
|
||||
myVcsHelper.onMerge {
|
||||
vcsHelper.onMerge {
|
||||
resolveConflicts(myRepo)
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
fun `test local changes are restored after successful abort`() {
|
||||
myRepo.`prepare simple conflict`()
|
||||
val localChange = LocalChange(myRepo, "new.txt", "content").generate()
|
||||
myVcsHelper.onMerge {}
|
||||
`do nothing on merge`()
|
||||
myDialogManager.onMessage { Messages.YES }
|
||||
|
||||
rebaseOnMaster()
|
||||
@@ -279,7 +279,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
fun `test local changes are not restored after failed abort`() {
|
||||
myRepo.`prepare simple conflict`()
|
||||
LocalChange(myRepo, "new.txt", "content").generate()
|
||||
myVcsHelper.onMerge {}
|
||||
`do nothing on merge`()
|
||||
myDialogManager.onMessage { Messages.YES }
|
||||
|
||||
rebaseOnMaster()
|
||||
@@ -358,7 +358,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
rebaseOnMaster()
|
||||
myRepo.assertConflict("c.txt")
|
||||
|
||||
myVcsHelper.onMerge {
|
||||
vcsHelper.onMerge {
|
||||
resolveConflicts(myRepo)
|
||||
}
|
||||
GitRebaseUtils.continueRebase(myProject)
|
||||
@@ -382,7 +382,7 @@ class GitSingleRepoRebaseTest : GitRebaseBaseTest() {
|
||||
|
||||
val hash2skip = DvcsUtil.getShortHash(git("log -2 --pretty=%H").lines()[1])
|
||||
|
||||
myVcsHelper.onMerge {
|
||||
vcsHelper.onMerge {
|
||||
file("c.txt").write("base\nmaster")
|
||||
resolveConflicts(myRepo)
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ abstract class GitPlatformTest : VcsPlatformTest() {
|
||||
protected lateinit var myVcs: GitVcs
|
||||
protected lateinit var myDialogManager: TestDialogManager
|
||||
protected lateinit var myVcsNotifier: TestVcsNotifier
|
||||
protected lateinit var vcsHelper: MockVcsHelper
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
@@ -51,6 +52,8 @@ abstract class GitPlatformTest : VcsPlatformTest() {
|
||||
myDialogManager = ServiceManager.getService(DialogManager::class.java) as TestDialogManager
|
||||
myVcsNotifier = ServiceManager.getService(myProject, VcsNotifier::class.java) as TestVcsNotifier
|
||||
|
||||
vcsHelper = GitTestUtil.overrideService(myProject, AbstractVcsHelper::class.java, MockVcsHelper::class.java)
|
||||
|
||||
myGitRepositoryManager = GitUtil.getRepositoryManager(myProject)
|
||||
myGit = GitTestUtil.overrideService(Git::class.java, TestGitImpl::class.java)
|
||||
myVcs = GitVcs.getInstance(myProject)!!
|
||||
@@ -114,6 +117,10 @@ abstract class GitPlatformTest : VcsPlatformTest() {
|
||||
hookFile.setExecutable(true, false)
|
||||
}
|
||||
|
||||
protected fun `do nothing on merge`() {
|
||||
vcsHelper.onMerge{}
|
||||
}
|
||||
|
||||
protected fun assertSuccessfulNotification(title: String, message: String) : Notification {
|
||||
return GitTestUtil.assertNotification(NotificationType.INFORMATION, title, message, myVcsNotifier.lastNotification)
|
||||
}
|
||||
@@ -139,4 +146,8 @@ abstract class GitPlatformTest : VcsPlatformTest() {
|
||||
fail("No notification is expected here, but this one was shown: ${notification.title}/${notification.content}");
|
||||
}
|
||||
}
|
||||
|
||||
protected fun `assert merge dialog was shown`() {
|
||||
assertTrue("Merge dialog was not shown", vcsHelper.mergeDialogWasShown())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user