mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
[Workspace Model] Update reload tests
Code review: IDEA-CR-65216 GitOrigin-RevId: 4c2079b1caddcb5a697f7154584a2e2a98cad9b7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
adb9a855a5
commit
8cc164f0e6
@@ -1 +0,0 @@
|
||||
sampleProjectName
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="?*.properties" />
|
||||
<entry name="?*.xml" />
|
||||
<entry name="?*.gif" />
|
||||
<entry name="?*.png" />
|
||||
<entry name="?*.jpeg" />
|
||||
<entry name="?*.jpg" />
|
||||
<entry name="?*.html" />
|
||||
<entry name="?*.dtd" />
|
||||
<entry name="?*.tld" />
|
||||
<entry name="?*.ftl" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing enabled="false" useClasspath="true" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="file://$PROJECT_DIR$/util" charset="windows-1251" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1 +0,0 @@
|
||||
sampleProjectName
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="?*.properties" />
|
||||
<entry name="?*.xml" />
|
||||
<entry name="?*.gif" />
|
||||
<entry name="?*.png" />
|
||||
<entry name="?*.jpeg" />
|
||||
<entry name="?*.jpg" />
|
||||
<entry name="?*.html" />
|
||||
<entry name="?*.dtd" />
|
||||
<entry name="?*.tld" />
|
||||
<entry name="?*.ftl" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing enabled="false" useClasspath="true" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="file://$PROJECT_DIR$/util" charset="windows-1251" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.configurationStore
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.testFramework.TemporaryDirectory
|
||||
import com.intellij.testFramework.createOrLoadProject
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.nio.file.Path
|
||||
|
||||
abstract class LoadProjectBase {
|
||||
|
||||
abstract val tempDirectory: TemporaryDirectory
|
||||
abstract val testDataRoot: Path
|
||||
|
||||
|
||||
protected fun loadProjectAndCheckResults(testDataDirName: String, checkProject: suspend (Project) -> Unit) {
|
||||
return loadProjectAndCheckResults(testDataRoot.resolve(testDataDirName), checkProject)
|
||||
}
|
||||
|
||||
protected fun loadProjectAndCheckResults(projectPath: Path, checkProject: suspend (Project) -> Unit) {
|
||||
@Suppress("RedundantSuspendModifier")
|
||||
suspend fun copyProjectFiles(dir: VirtualFile): Path {
|
||||
val projectDir = VfsUtil.virtualToIoFile(dir)
|
||||
FileUtil.copyDir(projectPath.toFile(), projectDir)
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, dir)
|
||||
return projectDir.toPath()
|
||||
}
|
||||
runBlocking {
|
||||
createOrLoadProject(tempDirectory, ::copyProjectFiles, loadComponentState = true, useDefaultProjectSettings = false) {
|
||||
checkProject(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,13 @@ package com.intellij.java.configurationStore
|
||||
import com.intellij.openapi.application.ex.PathManagerEx
|
||||
import com.intellij.openapi.application.runWriteActionAndWait
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||
import com.intellij.openapi.roots.libraries.Library
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.testFramework.ApplicationRule
|
||||
import com.intellij.testFramework.TemporaryDirectory
|
||||
import com.intellij.testFramework.createOrLoadProject
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryProperties
|
||||
import org.junit.ClassRule
|
||||
@@ -25,7 +19,7 @@ import org.junit.Test
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
class LoadProjectTest {
|
||||
class LoadProjectTest : LoadProjectBase() {
|
||||
companion object {
|
||||
@JvmField
|
||||
@ClassRule
|
||||
@@ -34,7 +28,13 @@ class LoadProjectTest {
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
val tempDirectory = TemporaryDirectory()
|
||||
val myTempDirectory = TemporaryDirectory()
|
||||
|
||||
override val tempDirectory: TemporaryDirectory
|
||||
get() = myTempDirectory
|
||||
|
||||
override val testDataRoot: Path
|
||||
get() = Paths.get(PathManagerEx.getCommunityHomePath()).resolve("java/java-tests/testData/configurationStore")
|
||||
|
||||
@Test
|
||||
fun `load single module`() {
|
||||
@@ -113,27 +113,4 @@ class LoadProjectTest {
|
||||
assertThat(withoutTransitive.properties.excludedDependencies).isEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
private val testDataRoot
|
||||
get() = Paths.get(PathManagerEx.getCommunityHomePath()).resolve("java/java-tests/testData/configurationStore")
|
||||
|
||||
private fun loadProjectAndCheckResults(testDataDirName: String, checkProject: (Project) -> Unit) {
|
||||
return loadProjectAndCheckResults(testDataRoot.resolve(testDataDirName), checkProject)
|
||||
}
|
||||
|
||||
private fun loadProjectAndCheckResults(projectPath: Path, checkProject: (Project) -> Unit) {
|
||||
@Suppress("RedundantSuspendModifier")
|
||||
suspend fun copyProjectFiles(dir: VirtualFile): Path {
|
||||
val projectDir = VfsUtil.virtualToIoFile(dir)
|
||||
FileUtil.copyDir(projectPath.toFile(), projectDir)
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, dir)
|
||||
return projectDir.toPath()
|
||||
}
|
||||
runBlocking {
|
||||
createOrLoadProject(tempDirectory, ::copyProjectFiles, loadComponentState = true, useDefaultProjectSettings = false) {
|
||||
checkProject(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,7 @@ import org.junit.Test
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
/**
|
||||
* This class has no specific Java test. It's located in intellij.java.tests module because if Java plugin is enabled additional elements
|
||||
* are added to iml file (e.g. 'exclude-output' tag) so if this test is located in a platform module it'll give different results dependening
|
||||
* on whether there is Java plugin in runtime classpath or not.
|
||||
*/
|
||||
class ReloadProjectTest {
|
||||
class ReloadProjectTest : LoadProjectBase() {
|
||||
companion object {
|
||||
@JvmField
|
||||
@ClassRule
|
||||
@@ -37,11 +32,17 @@ class ReloadProjectTest {
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
val tempDirectory = TemporaryDirectory()
|
||||
val myTempDirectory = TemporaryDirectory()
|
||||
|
||||
override val tempDirectory: TemporaryDirectory
|
||||
get() = myTempDirectory
|
||||
|
||||
override val testDataRoot
|
||||
get() = Paths.get(PathManagerEx.getCommunityHomePath()).resolve("java/java-tests/testData/reloading")
|
||||
|
||||
@Test
|
||||
internal fun `reload module with module library`() {
|
||||
loadProject("removeModuleWithModuleLibrary/before") { project ->
|
||||
loadProjectAndCheckResults("removeModuleWithModuleLibrary/before") { project ->
|
||||
val base = Paths.get(project.basePath!!)
|
||||
FileUtil.copyDir(testDataRoot.resolve("removeModuleWithModuleLibrary/after").toFile(), base.toFile())
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, VfsUtil.findFile(base, true))
|
||||
@@ -53,7 +54,7 @@ class ReloadProjectTest {
|
||||
|
||||
@Test
|
||||
fun `change iml`() {
|
||||
loadProject("changeIml/initial") { project ->
|
||||
loadProjectAndCheckResults("changeIml/initial") { project ->
|
||||
copyFilesAndReload(project, "changeIml/update")
|
||||
val module = ModuleManager.getInstance(project).modules.single()
|
||||
val srcUrl = VfsUtilCore.pathToUrl("${project.basePath}/src")
|
||||
@@ -71,26 +72,4 @@ class ReloadProjectTest {
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, VfsUtil.findFile(base, true))
|
||||
StoreReloadManager.getInstance().reloadChangedStorageFiles()
|
||||
}
|
||||
|
||||
private val testDataRoot
|
||||
get() = Paths.get(PathManagerEx.getCommunityHomePath()).resolve("java/java-tests/testData/reloading")
|
||||
|
||||
private fun loadProject(testDataDirName: String, checkProject: suspend (Project) -> Unit) {
|
||||
return loadProject(testDataRoot.resolve(testDataDirName), checkProject)
|
||||
}
|
||||
|
||||
private fun loadProject(projectPath: Path, checkProject: suspend (Project) -> Unit) {
|
||||
@Suppress("RedundantSuspendModifier")
|
||||
suspend fun copyProjectFiles(dir: VirtualFile): Path {
|
||||
val projectDir = VfsUtil.virtualToIoFile(dir)
|
||||
FileUtil.copyDir(projectPath.toFile(), projectDir)
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, dir)
|
||||
return projectDir.toPath()
|
||||
}
|
||||
runBlocking {
|
||||
createOrLoadProject(tempDirectory, ::copyProjectFiles, loadComponentState = true, useDefaultProjectSettings = false) {
|
||||
checkProject(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user