JS: fixed support for test source roots (KT-6627)
Original commit: 289a7a9cc3
This commit is contained in:
@@ -33,7 +33,6 @@ import org.jetbrains.jps.builders.CompileScopeTestBuilder
|
|||||||
import org.jetbrains.jps.builders.JpsBuildTestCase
|
import org.jetbrains.jps.builders.JpsBuildTestCase
|
||||||
import org.jetbrains.jps.builders.TestProjectBuilderLogger
|
import org.jetbrains.jps.builders.TestProjectBuilderLogger
|
||||||
import org.jetbrains.jps.builders.impl.BuildDataPathsImpl
|
import org.jetbrains.jps.builders.impl.BuildDataPathsImpl
|
||||||
import org.jetbrains.jps.builders.impl.logging.ProjectBuilderLoggerImpl
|
|
||||||
import org.jetbrains.jps.builders.logging.BuildLoggingManager
|
import org.jetbrains.jps.builders.logging.BuildLoggingManager
|
||||||
import org.jetbrains.jps.cmdline.ProjectDescriptor
|
import org.jetbrains.jps.cmdline.ProjectDescriptor
|
||||||
import org.jetbrains.jps.incremental.BuilderRegistry
|
import org.jetbrains.jps.incremental.BuilderRegistry
|
||||||
@@ -50,13 +49,10 @@ import org.jetbrains.jps.model.module.JpsModule
|
|||||||
import org.jetbrains.jps.util.JpsPathUtil
|
import org.jetbrains.jps.util.JpsPathUtil
|
||||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||||
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
|
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
|
||||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_ENABLED_PROPERTY
|
|
||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||||
import org.jetbrains.kotlin.incremental.withIC
|
import org.jetbrains.kotlin.incremental.withIC
|
||||||
import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.LibraryDependency.*
|
import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.LibraryDependency.*
|
||||||
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver.Companion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY
|
import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver.Companion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -376,6 +372,26 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME))
|
assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testKotlinJavaScriptProjectWithTests() {
|
||||||
|
initProject(JS_STDLIB)
|
||||||
|
makeAll().assertSuccessful()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testKotlinJavaScriptProjectWithTestsAndSeparateTestAndSrcModuleDependencies() {
|
||||||
|
initProject(JS_STDLIB)
|
||||||
|
makeAll().assertSuccessful()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testKotlinJavaScriptProjectWithTestsAndTestAndSrcModuleDependency() {
|
||||||
|
initProject(JS_STDLIB)
|
||||||
|
val buildResult = makeAll()
|
||||||
|
buildResult.assertSuccessful()
|
||||||
|
|
||||||
|
val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING)
|
||||||
|
assertEquals("Warning about duplicate module definition: $warnings", 1, warnings.size)
|
||||||
|
assertEquals("Module \"srcAndTests\" is defined in more, than one file", warnings.first().messageText)
|
||||||
|
}
|
||||||
|
|
||||||
fun testExcludeFolderInSourceRoot() {
|
fun testExcludeFolderInSourceRoot() {
|
||||||
doTest()
|
doTest()
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.jps.build
|
|||||||
import com.intellij.util.Consumer
|
import com.intellij.util.Consumer
|
||||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
|
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType
|
||||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||||
|
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||||
import org.jetbrains.jps.model.java.JpsJavaModuleType
|
import org.jetbrains.jps.model.java.JpsJavaModuleType
|
||||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||||
import org.jetbrains.jps.model.module.JpsModule
|
import org.jetbrains.jps.model.module.JpsModule
|
||||||
@@ -47,12 +48,21 @@ object JpsJsModuleUtils {
|
|||||||
fun getDependencyModulesAndSources(target: ModuleBuildTarget, result: MutableList<String>) {
|
fun getDependencyModulesAndSources(target: ModuleBuildTarget, result: MutableList<String>) {
|
||||||
JpsUtils.getAllDependencies(target).processModules(object : Consumer<JpsModule> {
|
JpsUtils.getAllDependencies(target).processModules(object : Consumer<JpsModule> {
|
||||||
override fun consume(module: JpsModule) {
|
override fun consume(module: JpsModule) {
|
||||||
if (module == target.module || module.moduleType != JpsJavaModuleType.INSTANCE) return
|
if (module.moduleType != JpsJavaModuleType.INSTANCE) return
|
||||||
|
|
||||||
val moduleBuildTarget = ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)
|
for (root in module.sourceRoots) {
|
||||||
val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(moduleBuildTarget)
|
val isTestSource = root.rootType == JavaSourceRootType.TEST_SOURCE
|
||||||
val metaInfoFile = getOutputMetaFile(outputDir, module.name)
|
|
||||||
result.add(metaInfoFile.absolutePath)
|
if (module == target.module && isTestSource == target.isTests) continue
|
||||||
|
|
||||||
|
if (!isTestSource || target.isTests) {
|
||||||
|
val targetType = if (isTestSource) JavaModuleBuildTargetType.TEST else JavaModuleBuildTargetType.PRODUCTION
|
||||||
|
val moduleBuildTarget = ModuleBuildTarget(module, targetType)
|
||||||
|
val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(moduleBuildTarget)
|
||||||
|
val metaInfoFile = getOutputMetaFile(outputDir, module.name)
|
||||||
|
result.add(metaInfoFile.absolutePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?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" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fun main() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun testMain() {
|
||||||
|
main()
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<?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" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="srcOnly" />
|
||||||
|
<orderEntry type="module" module-name="testsOnly" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/srcOnly/srcOnly.iml" filepath="$PROJECT_DIR$/srcOnly/srcOnly.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/testsOnly/testsOnly.iml" filepath="$PROJECT_DIR$/testsOnly/testsOnly.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun main() {
|
||||||
|
srcOnly()
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
fun srcOnly() {}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
<?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>
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun testMain() {
|
||||||
|
main()
|
||||||
|
srcOnly()
|
||||||
|
testsOnly()
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
fun testsOnly() {}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
<?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$/tests" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?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" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="srcAndTests" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/srcAndTests/srcAndTests.iml" filepath="$PROJECT_DIR$/srcAndTests/srcAndTests.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun main() {
|
||||||
|
srcAndTests()
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
fun srcAndTests() {}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?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" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
fun testSrcAndTests() {
|
||||||
|
srcAndTests()
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun testMain() {
|
||||||
|
main()
|
||||||
|
srcAndTests()
|
||||||
|
testSrcAndTests()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user