mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs] Added call to ChangeListManagerImpl.update() before requesting the file history to fix flakiness of test.
GitOrigin-RevId: 8430181eb5c59a9afc9a2e2466f207e872561210
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dbe582ee4c
commit
ed3ae46a60
@@ -26,6 +26,7 @@ import git4idea.history.GitLogParser.GitLogOption
|
||||
import git4idea.log.GitLogProvider
|
||||
import git4idea.repo.GitRepositoryManager
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
@@ -87,6 +88,9 @@ class GitFileHistory internal constructor(private val project: Project,
|
||||
}
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
internal fun getFilePath() = path
|
||||
|
||||
@Throws(VcsException::class)
|
||||
private fun runGitLog(logParser: GitLogParser<GitLogFullRecord>,
|
||||
startPath: FilePath,
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vcs.Executor.*
|
||||
import com.intellij.openapi.vcs.VcsException
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.util.CollectConsumer
|
||||
@@ -82,7 +83,7 @@ class GitFileHistoryTest : GitSingleRepoTest() {
|
||||
val file = commits.first().file
|
||||
|
||||
val history = collectFileHistory(file)
|
||||
assertSameHistory(commits, history, "History is different for file${file.relativePath()}.")
|
||||
assertSameHistory(commits, history, file)
|
||||
}
|
||||
|
||||
@Throws(VcsException::class, IOException::class)
|
||||
@@ -317,9 +318,9 @@ class GitFileHistoryTest : GitSingleRepoTest() {
|
||||
val monorepoMergeFile2 = TestCommit(monorepoMerge, monorepoMergeMessage, repo.root, repo2MovedFile)
|
||||
|
||||
assertSameHistory((commits + monorepoMergeFile1).sortedBy { it.hash },
|
||||
collectFileHistory(repo1MovedFile, full = true).sortedBy { it.revisionNumber.asString() })
|
||||
collectFileHistory(repo1MovedFile, full = true).sortedBy { it.revisionNumber.asString() }, repo1MovedFile)
|
||||
assertSameHistory((commits + monorepoMergeFile2).sortedBy { it.hash },
|
||||
collectFileHistory(repo2MovedFile, full = true).sortedBy { it.revisionNumber.asString() })
|
||||
collectFileHistory(repo2MovedFile, full = true).sortedBy { it.revisionNumber.asString() }, repo2MovedFile)
|
||||
}
|
||||
|
||||
@Throws(VcsException::class, IOException::class)
|
||||
@@ -382,16 +383,20 @@ class GitFileHistoryTest : GitSingleRepoTest() {
|
||||
}
|
||||
|
||||
private fun collectFileHistory(file: File, startingRevisions: List<String>, full: Boolean): List<VcsFileRevision> {
|
||||
VcsDirtyScopeManager.getInstance(project).markEverythingDirty()
|
||||
ChangeListManagerImpl.getInstanceImpl(project).waitEverythingDoneInTestMode()
|
||||
|
||||
val path = VcsUtil.getFilePath(file, false)
|
||||
val gitFileHistory = GitFileHistory(myProject, repo.root, path, startingRevisions, full)
|
||||
TestCase.assertEquals("Last commit path differs from the requested one", path, gitFileHistory.getFilePath())
|
||||
return buildList {
|
||||
GitFileHistory(myProject, repo.root, path, startingRevisions, full).load(::add)
|
||||
gitFileHistory.load(::add)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertSameHistory(expected: List<TestCommit>, actual: List<VcsFileRevision>, message: String = "History is different.") {
|
||||
TestCase.assertEquals(message, expected, actual.map { it.toTestCommit() })
|
||||
private fun assertSameHistory(expected: List<TestCommit>, actual: List<VcsFileRevision>, file: File? = null) {
|
||||
val description = if (file == null) "History is different." else "History for ${file.relativePath()} is different."
|
||||
TestCase.assertEquals(description, expected, actual.map { it.toTestCommit() })
|
||||
}
|
||||
|
||||
private data class TestCommit(val hash: String, val commitMessage: String, val root: VirtualFile, val file: File) {
|
||||
|
||||
Reference in New Issue
Block a user