Fix modules tests
This commit is contained in:
+1
-2
@@ -17,7 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.cli.common.modules
|
package org.jetbrains.kotlin.cli.common.modules
|
||||||
|
|
||||||
import org.jetbrains.kotlin.modules.Module
|
import org.jetbrains.kotlin.modules.Module
|
||||||
import java.util.ArrayList
|
import java.util.*
|
||||||
|
|
||||||
public class ModuleBuilder(
|
public class ModuleBuilder(
|
||||||
private val name: String,
|
private val name: String,
|
||||||
@@ -53,4 +53,3 @@ public class ModuleBuilder(
|
|||||||
override fun getModuleName(): String = name
|
override fun getModuleName(): String = name
|
||||||
override fun getModuleType(): String = type
|
override fun getModuleType(): String = type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-13
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.cli.common.modules;
|
|||||||
import com.intellij.openapi.util.io.StreamUtil;
|
import com.intellij.openapi.util.io.StreamUtil;
|
||||||
import com.intellij.util.SmartList;
|
import com.intellij.util.SmartList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil;
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil;
|
||||||
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil;
|
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil;
|
||||||
@@ -43,6 +42,8 @@ public class ModuleXmlParser {
|
|||||||
public static final String MODULE = "module";
|
public static final String MODULE = "module";
|
||||||
public static final String NAME = "name";
|
public static final String NAME = "name";
|
||||||
public static final String TYPE = "type";
|
public static final String TYPE = "type";
|
||||||
|
public static final String TYPE_PRODUCTION = "java-production";
|
||||||
|
public static final String TYPE_TEST = "java-test";
|
||||||
public static final String OUTPUT_DIR = "outputDir";
|
public static final String OUTPUT_DIR = "outputDir";
|
||||||
public static final String SOURCES = "sources";
|
public static final String SOURCES = "sources";
|
||||||
public static final String JAVA_SOURCE_ROOTS = "javaSourceRoots";
|
public static final String JAVA_SOURCE_ROOTS = "javaSourceRoots";
|
||||||
@@ -127,24 +128,15 @@ public class ModuleXmlParser {
|
|||||||
throw createError(qName);
|
throw createError(qName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String moduleType = getAttribute(attributes, TYPE, qName);
|
||||||
|
assert(TYPE_PRODUCTION.equals(moduleType) || TYPE_TEST.equals(moduleType)): "Unknown module type: " + moduleType;
|
||||||
setCurrentState(new InsideModule(
|
setCurrentState(new InsideModule(
|
||||||
getAttribute(attributes, NAME, qName),
|
getAttribute(attributes, NAME, qName),
|
||||||
getAttribute(attributes, OUTPUT_DIR, qName),
|
getAttribute(attributes, OUTPUT_DIR, qName),
|
||||||
getType(attributes, qName)
|
moduleType
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private String getType(@NotNull Attributes attributes, @NotNull String tag) {
|
|
||||||
String value = attributes.getValue(TYPE);
|
|
||||||
|
|
||||||
assert value != null &&
|
|
||||||
(JavaModuleBuildTargetType.PRODUCTION.getTypeId().equals(value) ||
|
|
||||||
JavaModuleBuildTargetType.TEST.getTypeId().equals(value)): "Unknown value of module type: " + value;
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, @NotNull String localName, @NotNull String qName) throws SAXException {
|
public void endElement(String uri, @NotNull String localName, @NotNull String qName) throws SAXException {
|
||||||
if (MODULE.equalsIgnoreCase(qName) || MODULES.equalsIgnoreCase(qName)) {
|
if (MODULE.equalsIgnoreCase(qName) || MODULES.equalsIgnoreCase(qName)) {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="whatever">
|
<module name="name" outputDir="whatever" type="java-production">
|
||||||
<sources path="duplicateSourcesInModule.kt"/>
|
<sources path="duplicateSourcesInModule.kt"/>
|
||||||
<sources path="duplicateSourcesInModule.kt"/>
|
<sources path="duplicateSourcesInModule.kt"/>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
name
|
name
|
||||||
|
type=java-production
|
||||||
outputDir=out
|
outputDir=out
|
||||||
sources=[foo]
|
sources=[foo]
|
||||||
classpath=[bar]
|
classpath=[bar]
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="out">
|
<module name="name" outputDir="out" type="java-production">
|
||||||
<sources path="foo"/>
|
<sources path="foo"/>
|
||||||
<classpath path="bar"/>
|
<classpath path="bar"/>
|
||||||
<externalAnnotations path="baz"/>
|
<externalAnnotations path="baz"/>
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
name
|
name
|
||||||
|
type=java-production
|
||||||
outputDir=out
|
outputDir=out
|
||||||
sources=[foo, foo1, foo2]
|
sources=[foo, foo1, foo2]
|
||||||
classpath=[bar1, bar2]
|
classpath=[bar1, bar2]
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="out">
|
<module name="name" outputDir="out" type="java-production">
|
||||||
<sources path="foo"/>
|
<sources path="foo"/>
|
||||||
<sources path="foo1"/>
|
<sources path="foo1"/>
|
||||||
<sources path="foo2"/>
|
<sources path="foo2"/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
name
|
name
|
||||||
|
type=java-production
|
||||||
outputDir=out
|
outputDir=out
|
||||||
sources=[]
|
sources=[]
|
||||||
classpath=[]
|
classpath=[]
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="out"/>
|
<module name="name" outputDir="out" type="java-production"/>
|
||||||
</modules>
|
</modules>
|
||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
name
|
name
|
||||||
|
type=java-production
|
||||||
outputDir=out
|
outputDir=out
|
||||||
sources=[foo, foo1, foo2]
|
sources=[foo, foo1, foo2]
|
||||||
classpath=[bar, bar1, bar2]
|
classpath=[bar, bar1, bar2]
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="out">
|
<module name="name" outputDir="out" type="java-production">
|
||||||
<sources path="foo"/>
|
<sources path="foo"/>
|
||||||
<sources path="foo1"/>
|
<sources path="foo1"/>
|
||||||
<sources path="foo2"/>
|
<sources path="foo2"/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
name
|
name
|
||||||
|
type=java-production
|
||||||
outputDir=out
|
outputDir=out
|
||||||
sources=[foo]
|
sources=[foo]
|
||||||
classpath=[]
|
classpath=[]
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="out">
|
<module name="name" outputDir="out" type="java-production">
|
||||||
<sources path="foo"/>
|
<sources path="foo"/>
|
||||||
</module>
|
</module>
|
||||||
</modules>
|
</modules>
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
name
|
name
|
||||||
|
type=java-production
|
||||||
outputDir=out
|
outputDir=out
|
||||||
sources=[foo, foo1, foo2]
|
sources=[foo, foo1, foo2]
|
||||||
classpath=[bar, bar1, bar2]
|
classpath=[bar, bar1, bar2]
|
||||||
annotations=[baz, baz1, baz2]
|
annotations=[baz, baz1, baz2]
|
||||||
name2
|
name2
|
||||||
|
type=java-production
|
||||||
outputDir=out2
|
outputDir=out2
|
||||||
sources=[2foo, 2foo1, 2foo2]
|
sources=[2foo, 2foo1, 2foo2]
|
||||||
classpath=[2bar, 2bar1, 2bar2]
|
classpath=[2bar, 2bar1, 2bar2]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module name="name" outputDir="out">
|
<module name="name" outputDir="out" type="java-production">
|
||||||
<sources path="foo"/>
|
<sources path="foo"/>
|
||||||
<sources path="foo1"/>
|
<sources path="foo1"/>
|
||||||
<sources path="foo2"/>
|
<sources path="foo2"/>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<externalAnnotations path="baz1"/>
|
<externalAnnotations path="baz1"/>
|
||||||
<externalAnnotations path="baz2"/>
|
<externalAnnotations path="baz2"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="name2" outputDir="out2">
|
<module name="name2" outputDir="out2" type="java-production">
|
||||||
<sources path="2foo"/>
|
<sources path="2foo"/>
|
||||||
<sources path="2foo1"/>
|
<sources path="2foo1"/>
|
||||||
<sources path="2foo2"/>
|
<sources path="2foo2"/>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
name
|
||||||
|
type=java-test
|
||||||
|
outputDir=out
|
||||||
|
sources=[]
|
||||||
|
classpath=[]
|
||||||
|
annotations=[]
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<modules>
|
||||||
|
<module name="name" outputDir="out" type="java-test"/>
|
||||||
|
</modules>
|
||||||
@@ -76,4 +76,10 @@ public class ModuleXmlParserTestGenerated extends AbstractModuleXmlParserTest {
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/modules.xml/twoModules.xml");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/modules.xml/twoModules.xml");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeTestModule.xml")
|
||||||
|
public void testTypeTestModule() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/modules.xml/typeTestModule.xml");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<!-- Module script for production -->
|
<!-- Module script for production -->
|
||||||
<module name="name" outputDir="output">
|
<module name="name" type="java-production" outputDir="output">
|
||||||
<sources path="s1"/>
|
<sources path="s1"/>
|
||||||
<sources path="s2"/>
|
<sources path="s2"/>
|
||||||
<!-- Java source roots -->
|
<!-- Java source roots -->
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<!-- Module script for production -->
|
<!-- Module script for production -->
|
||||||
<module name="name" outputDir="output">
|
<module name="name" type="java-production" outputDir="output">
|
||||||
<sources path="s1"/>
|
<sources path="s1"/>
|
||||||
<sources path="s2"/>
|
<sources path="s2"/>
|
||||||
<!-- Java source roots -->
|
<!-- Java source roots -->
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<!-- Module script for production -->
|
<!-- Module script for production -->
|
||||||
<module name="name" outputDir="output">
|
<module name="name" type="java-production" outputDir="output">
|
||||||
<sources path="s1"/>
|
<sources path="s1"/>
|
||||||
<sources path="s2"/>
|
<sources path="s2"/>
|
||||||
<!-- Java source roots -->
|
<!-- Java source roots -->
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<externalAnnotations path="a2"/>
|
<externalAnnotations path="a2"/>
|
||||||
</module>
|
</module>
|
||||||
<!-- Module script for tests -->
|
<!-- Module script for tests -->
|
||||||
<module name="name2" outputDir="output2">
|
<module name="name2" type="java-test" outputDir="output2">
|
||||||
<sources path="s12"/>
|
<sources path="s12"/>
|
||||||
<sources path="s22"/>
|
<sources path="s22"/>
|
||||||
<!-- Java source roots -->
|
<!-- Java source roots -->
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.jetbrains.jps.builders.BuildResult
|
|||||||
import org.jetbrains.jps.builders.CompileScopeTestBuilder
|
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.logging.BuildLoggingManager
|
import org.jetbrains.jps.builders.logging.BuildLoggingManager
|
||||||
import org.jetbrains.jps.incremental.BuilderRegistry
|
import org.jetbrains.jps.incremental.BuilderRegistry
|
||||||
import org.jetbrains.jps.incremental.IncProjectBuilder
|
import org.jetbrains.jps.incremental.IncProjectBuilder
|
||||||
@@ -52,10 +51,7 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor
|
|||||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.Arrays
|
import java.util.*
|
||||||
import java.util.Collections
|
|
||||||
import java.util.HashSet
|
|
||||||
import java.util.TreeSet
|
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import java.util.zip.ZipOutputStream
|
import java.util.zip.ZipOutputStream
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
@@ -539,15 +535,6 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
|||||||
makeAll().assertSuccessful()
|
makeAll().assertSuccessful()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun testDoNotCreateUselessKotlinIncrementalCaches() {
|
|
||||||
initProject()
|
|
||||||
makeAll().assertSuccessful()
|
|
||||||
|
|
||||||
val storageRoot = BuildDataPathsImpl(myDataStorageRoot).getDataStorageRoot()
|
|
||||||
assertTrue(File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists())
|
|
||||||
assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists())
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun testCancelLongKotlinCompilation() {
|
public fun testCancelLongKotlinCompilation() {
|
||||||
generateLongKotlinFile("Foo.kt", "foo", "Foo")
|
generateLongKotlinFile("Foo.kt", "foo", "Foo")
|
||||||
initProject()
|
initProject()
|
||||||
|
|||||||
Reference in New Issue
Block a user