summaryrefslogtreecommitdiff
path: root/plugins/kotlin/jps/jps-plugin/tests/test/org/jetbrains/kotlin/jps/build/AbstractMultiplatformJpsTest.kt
blob: ec585bdb4701b34504f54893e18304dba3917674 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package org.jetbrains.kotlin.jps.build

import org.jetbrains.kotlin.jps.build.dependeciestxt.ModulesTxt
import org.jetbrains.kotlin.jps.build.dependeciestxt.MppJpsIncTestsGenerator
import java.io.File

abstract class AbstractMultiplatformJpsTestWithGeneratedContent : AbstractIncrementalJpsTest() {
    override val modulesTxtFile: File
        get() = File(testDataDir.parent, "dependencies.txt").also {
            check(it.exists()) {
                "`dependencies.txt` should be in parent dir. " +
                        "See `jps-plugin/tests/testData/incremental/multiModule/multiplatform/withGeneratedContent/README.md` for details"
            }
        }

    override val testDataSrc: File
        get() = File(workDir, "generatedTestDataSources")

    override fun generateModuleSources(modulesTxt: ModulesTxt) {
        testDataSrc.mkdirs()

        val testCaseName = testDataDir.name

        val generator = MppJpsIncTestsGenerator(modulesTxt) { testDataSrc }
        val testCase = generator.testCases.find { it.name == testCaseName }
            ?: error("Test case `$testCaseName` is not configured in ${modulesTxt.fileName}")
        testCase.generate()
    }

    override val ModulesTxt.Module.sourceFilePrefix: String
        get() = "${indexedName}_"
}