JPS, native: skip and report native modules as not supported

#KT-26648 Fixed

Original commit: 9e6d6ad9da
This commit is contained in:
Sergey Rostov
2018-09-10 17:25:43 +03:00
parent bc766111a6
commit e47d796bd7
10 changed files with 217 additions and 15 deletions
@@ -552,6 +552,7 @@ abstract class AbstractIncrementalJpsTest(
private class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase(), TestingBuildLogger {
private val markedDirtyBeforeRound = ArrayList<File>()
private val markedDirtyAfterRound = ArrayList<File>()
private val customMessages = mutableListOf<String>()
override fun invalidOrUnusedCache(
chunk: KotlinChunk?,
@@ -588,7 +589,15 @@ abstract class AbstractIncrementalJpsTest(
logDirtyFiles(markedDirtyBeforeRound)
}
override fun addCustomMessage(message: String) {
customMessages.add(message)
}
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {
customMessages.forEach {
logLine(it)
}
customMessages.clear()
logDirtyFiles(markedDirtyAfterRound)
logLine("Exit code: $exitCode")
logLine("------------------------------------------")
@@ -1001,6 +1001,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
target: KotlinModuleBuildTarget<*>?,
attributesDiff: CacheAttributesDiff<*>
) {}
override fun addCustomMessage(message: String) {}
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {}
override fun markedAsDirtyBeforeRound(files: Iterable<File>) {}
override fun markedAsDirtyAfterRound(files: Iterable<File>) {}
@@ -29,6 +29,37 @@ public class MultiplatformJpsTestWithGeneratedContentGenerated extends AbstractM
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class IgnoreAndWarnAboutNative extends AbstractMultiplatformJpsTestWithGeneratedContent {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInIgnoreAndWarnAboutNative() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("editingCKotlin")
public void testEditingCKotlin() throws Exception {
runTest("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin/");
}
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class EditingCKotlin extends AbstractMultiplatformJpsTestWithGeneratedContent {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInEditingCKotlin() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/ignoreAndWarnAboutNative/editingCKotlin"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("jps-plugin/testData/incremental/multiModule/multiplatform/withGeneratedContent/simple")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.config.KotlinFacetSettings
import org.jetbrains.kotlin.config.KotlinModuleKind.COMPILATION_AND_SOURCE_SET_HOLDER
import org.jetbrains.kotlin.config.KotlinModuleKind.SOURCE_SET_HOLDER
import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt.Dependency.Kind.*
import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments
import org.jetbrains.kotlin.platform.impl.isCommon
import org.jetbrains.kotlin.platform.impl.isJvm
import java.io.File
@@ -168,15 +169,19 @@ class ModulesTxtBuilder {
}
fun readFile(file: File, fileTitle: String = file.toString()): ModulesTxt {
file.forEachLine { line ->
parseDeclaration(line)
try {
file.forEachLine { line ->
parseDeclaration(line)
}
// dependencies need to be build first: module.build() requires it
val dependencies = dependencies.map { it.build() }
val modules = modules.values.mapIndexed { index, moduleRef -> moduleRef.build(index) }
return ModulesTxt(muted, file, fileTitle, modules, dependencies)
} catch (t: Throwable) {
throw Error("Error while reading $file: ${t.message}", t)
}
// dependencies need to be build first: module.build() requires it
val dependencies = dependencies.map { it.build() }
val modules = modules.values.mapIndexed { index, moduleRef -> moduleRef.build(index) }
return ModulesTxt(muted, file, fileTitle, modules, dependencies)
}
private fun parseDeclaration(line: String) = doParseDeclaration(removeComments(line))
@@ -251,6 +256,7 @@ class ModulesTxtBuilder {
"common" -> settings.compilerArguments = K2MetadataCompilerArguments()
"jvm" -> settings.compilerArguments = K2JVMCompilerArguments()
"js" -> settings.compilerArguments = K2JSCompilerArguments()
"native" -> settings.compilerArguments = FakeK2NativeCompilerArguments()
else -> {
val flagProperty = ModulesTxt.Module.flags[flag]
if (flagProperty != null) flagProperty.set(module, true)