mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-04 20:30:42 +07:00
Otherwise, dependency from 'intellij.maven.ultimate.testFramework' module to 'intellij.idea.ultimate.tests.main' breaks the generation of the module repository: the latter is considered as a test-only module, so a descriptor for its production part isn't generated, but the production part of the former has a dependency on it. It's possible to fix this by using 'test' scope for such dependencies or by adding more exceptions in 'isTestOnly' check, but it's not reliable. Given that we already have the problems with 'isTestOnly' heuristics in the past, it's better to get rid of it. This results in about 200 more descriptors created for IntelliJ Ultimate project, but this shouldn't be a problem especially when we start using more compact storage for the runtime module repository. GitOrigin-RevId: 613c5d4a55ae853e774ded31a4ab5345646ac2e9
191 lines
6.4 KiB
Kotlin
191 lines
6.4 KiB
Kotlin
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
package com.intellij.devkit.runtimeModuleRepository.jps.build
|
|
|
|
import org.jetbrains.jps.model.java.JavaResourceRootType
|
|
import org.jetbrains.jps.model.java.JpsJavaDependencyScope
|
|
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
|
import org.jetbrains.jps.model.java.JpsJavaLibraryType
|
|
import org.jetbrains.jps.model.library.JpsOrderRootType
|
|
import org.jetbrains.jps.util.JpsPathUtil
|
|
|
|
class RuntimeModuleRepositoryBuilderTest : RuntimeModuleRepositoryTestCase() {
|
|
fun `test module with tests`() {
|
|
addModule("a", withTests = true)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
testDescriptor("a.tests", "a")
|
|
}
|
|
}
|
|
|
|
fun `test module without sources`() {
|
|
addModule("a", withTests = false, withSources = false)
|
|
buildAndCheck {
|
|
descriptor("a", resourceDirName = null)
|
|
}
|
|
}
|
|
|
|
fun `test module with resources only`() {
|
|
val module = addModule("a", withTests = false, withSources = false)
|
|
module.addSourceRoot(getUrl("a/res"), JavaResourceRootType.RESOURCE)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
}
|
|
}
|
|
|
|
fun `test dependency`() {
|
|
val a = addModule("a", withTests = false)
|
|
addModule("b", a, withTests = false)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
descriptor("b", "a")
|
|
}
|
|
}
|
|
|
|
fun `test transitive dependency`() {
|
|
val a = addModule("a", withTests = false)
|
|
val b = addModule("b", a, withTests = false)
|
|
addModule("c", b, withTests = false)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
descriptor("b", "a")
|
|
descriptor("c", "b")
|
|
}
|
|
}
|
|
|
|
fun `test dependency with tests`() {
|
|
val a = addModule("a", withTests = true)
|
|
addModule("b", a, withTests = true)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
testDescriptor("a.tests", "a")
|
|
descriptor("b", "a")
|
|
testDescriptor("b.tests", "b", "a", "a.tests")
|
|
}
|
|
}
|
|
|
|
fun `test dependency on test only module with non-standard name`() {
|
|
val aTests = addModule("a.test", withSources = false, withTests = true)
|
|
val b = addModule("b", withTests = true)
|
|
val dependency = b.dependenciesList.addModuleDependency(aTests)
|
|
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).scope = JpsJavaDependencyScope.TEST
|
|
buildAndCheck {
|
|
descriptor("a.test", resourceDirName = null)
|
|
testDescriptor("a.test.tests", resourceDirName = "a.test")
|
|
descriptor("b")
|
|
testDescriptor("b.tests", "b", "a.test.tests")
|
|
}
|
|
}
|
|
|
|
fun `test transitive dependency via module without tests`() {
|
|
val a = addModule("a", withTests = true)
|
|
val b = addModule("b", a, withTests = false)
|
|
addModule("c", b, withTests = true)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
descriptor("b", "a")
|
|
descriptor("c", "b")
|
|
testDescriptor("a.tests", "a")
|
|
testDescriptor("c.tests", "c", "b", "a.tests")
|
|
}
|
|
}
|
|
|
|
fun `test do not add unnecessary transitive dependencies via module without tests`() {
|
|
val a = addModule("a", withTests = true)
|
|
val b = addModule("b", withTests = false)
|
|
val c = addModule("c", a, b, withTests = false)
|
|
addModule("d", c, withTests = true)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
descriptor("b")
|
|
descriptor("c", "a", "b")
|
|
descriptor("d", "c")
|
|
testDescriptor("a.tests", "a")
|
|
testDescriptor("d.tests", "d", "c", "a.tests")
|
|
}
|
|
}
|
|
|
|
fun `test circular dependency with tests`() {
|
|
val a = addModule("a", withTests = true)
|
|
val b = addModule("b", a, withTests = true)
|
|
val dependency = a.dependenciesList.addModuleDependency(b)
|
|
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).scope = JpsJavaDependencyScope.RUNTIME
|
|
buildAndCheck {
|
|
descriptor("a", "b")
|
|
testDescriptor("a.tests", "a", "b", "b.tests")
|
|
descriptor("b", "a")
|
|
testDescriptor("b.tests", "b", "a", "a.tests")
|
|
}
|
|
}
|
|
|
|
fun `test circular dependency without tests`() {
|
|
val a = addModule("a", withTests = false)
|
|
val b = addModule("b", a, withTests = false)
|
|
val dependency = a.dependenciesList.addModuleDependency(b)
|
|
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).scope = JpsJavaDependencyScope.RUNTIME
|
|
addModule("c", b, withTests = true)
|
|
buildAndCheck {
|
|
descriptor("a", "b")
|
|
descriptor("b", "a")
|
|
descriptor("c", "b")
|
|
testDescriptor("c.tests", "c", "b")
|
|
}
|
|
}
|
|
|
|
fun `test separate module for tests`() {
|
|
val a = addModule("a", withTests = false)
|
|
addModule("a.tests", a, withTests = true, withSources = false)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
testDescriptor("a.tests", "a", resourceDirName = "a.tests")
|
|
}
|
|
}
|
|
|
|
fun `test module with production roots named like a test module`() {
|
|
val name = "a.tests.actually.not"
|
|
addModule(name, withTests = false)
|
|
buildAndCheck {
|
|
descriptor(name)
|
|
descriptor(name)
|
|
}
|
|
}
|
|
|
|
fun `test module library`() {
|
|
val a = addModule("a", withTests = false)
|
|
val lib = a.libraryCollection.addLibrary("lib", JpsJavaLibraryType.INSTANCE)
|
|
a.dependenciesList.addLibraryDependency(lib)
|
|
val libraryRoot = getUrl("lib")
|
|
lib.addRoot(libraryRoot, JpsOrderRootType.COMPILED)
|
|
buildAndCheck {
|
|
descriptor("a", "lib.a.lib")
|
|
descriptor("lib.a.lib", listOf(JpsPathUtil.urlToPath(libraryRoot)), emptyList())
|
|
}
|
|
}
|
|
|
|
fun `test project library`() {
|
|
val a = addModule("a", withTests = false)
|
|
val lib = myProject.libraryCollection.addLibrary("lib", JpsJavaLibraryType.INSTANCE)
|
|
a.dependenciesList.addLibraryDependency(lib)
|
|
val libraryRoot = getUrl("lib")
|
|
lib.addRoot(libraryRoot, JpsOrderRootType.COMPILED)
|
|
buildAndCheck {
|
|
descriptor("a", "lib.lib")
|
|
descriptor("lib.lib", listOf(JpsPathUtil.urlToPath(libraryRoot)), emptyList())
|
|
}
|
|
}
|
|
|
|
fun `test library with test scope`() {
|
|
val a = addModule("a", withTests = true)
|
|
val lib = myProject.libraryCollection.addLibrary("lib", JpsJavaLibraryType.INSTANCE)
|
|
val dependency = a.dependenciesList.addLibraryDependency(lib)
|
|
JpsJavaExtensionService.getInstance().getOrCreateDependencyExtension(dependency).scope = JpsJavaDependencyScope.TEST
|
|
val libraryRoot = getUrl("lib")
|
|
lib.addRoot(libraryRoot, JpsOrderRootType.COMPILED)
|
|
buildAndCheck {
|
|
descriptor("a")
|
|
testDescriptor("a.tests", "a", "lib.lib")
|
|
descriptor("lib.lib", listOf(JpsPathUtil.urlToPath(libraryRoot)), emptyList())
|
|
}
|
|
}
|
|
}
|
|
|