KJS: write minification's test results to separate directory

It allows excluding this directory from indexing inside IDEA
and probably simplifies the main workflow.
This commit is contained in:
Zalim Bashorov
2017-11-14 13:32:30 +03:00
parent 18261838b6
commit 4849bddde1
8 changed files with 23 additions and 14 deletions
+2 -1
View File
@@ -18,7 +18,8 @@ workspace.xml
/ultimate/ideaSDK
/ultimate/out
/ultimate/tmp
/js/js.translator/testData/**/out/
/js/js.translator/testData/out/
/js/js.translator/testData/out-min/
.gradle/
build/
!**/src/**/build
@@ -74,13 +74,17 @@ import java.util.regex.Pattern
abstract class BasicBoxTest(
protected val pathToTestDir: String,
private val pathToOutputDir: String,
testGroupOutputDirPrefix: String,
pathToRootOutputDir: String = BasicBoxTest.TEST_DATA_DIR_PATH,
private val typedArraysEnabled: Boolean = true,
private val generateSourceMap: Boolean = false,
private val generateNodeJsRunner: Boolean = true
) : KotlinTestWithEnvironment() {
val additionalCommonFileDirectories = mutableListOf<String>()
private val testGroupOutputDirForCompilation = File(pathToRootOutputDir + "out/" + testGroupOutputDirPrefix)
private val testGroupOutputDirForMinification = File(pathToRootOutputDir + "out-min/" + testGroupOutputDirPrefix)
protected open fun getOutputPrefixFile(testFilePath: String): File? = null
protected open fun getOutputPostfixFile(testFilePath: String): File? = null
@@ -196,8 +200,9 @@ abstract class BasicBoxTest(
}
}
val outputDirForMinification = getOutputDir(file, testGroupOutputDirForMinification)
minifyAndRun(
workDir = File(File(outputDir, "min"), file.nameWithoutExtension),
workDir = File(outputDirForMinification, file.nameWithoutExtension),
allJsFiles = allJsFiles,
generatedJsFiles = generatedJsFiles,
expectedResult = expectedResult,
@@ -254,13 +259,13 @@ abstract class BasicBoxTest(
return sb.toString()
}
protected fun getOutputDir(file: File): File {
protected fun getOutputDir(file: File, testGroupOutputDir: File = testGroupOutputDirForCompilation): File {
val stopFile = File(pathToTestDir)
return generateSequence(file.parentFile) { it.parentFile }
.takeWhile { it != stopFile }
.map { it.name }
.toList().asReversed()
.fold(File(pathToOutputDir), ::File)
.fold(testGroupOutputDir, ::File)
}
private fun TestModule.outputFileSimpleName(): String {
@@ -21,7 +21,7 @@ import java.io.File
abstract class AbstractOutputPrefixPostfixTest : BasicBoxTest(
BasicBoxTest.TEST_DATA_DIR_PATH + "outputPrefixPostfix/",
"${BasicBoxTest.TEST_DATA_DIR_PATH}/out/outputPrefixPostfix/",
"outputPrefixPostfix/",
generateNodeJsRunner = false
) {
override fun getOutputPrefixFile(testFilePath: String): File? {
@@ -26,7 +26,7 @@ import javax.script.ScriptException
abstract class AbstractWebDemoExamplesTest(relativePath: String) : BasicBoxTest(
BasicBoxTest.TEST_DATA_DIR_PATH + "/$relativePath/",
BasicBoxTest.TEST_DATA_DIR_PATH + "out/$relativePath/",
relativePath,
generateNodeJsRunner = false
) {
override fun runGeneratedCode(
@@ -21,7 +21,10 @@ import org.jetbrains.kotlin.js.test.NashornJsTestChecker
import java.io.File
import javax.script.ScriptException
class MultiModuleOrderTest : BasicBoxTest("$TEST_DATA_DIR_PATH/multiModuleOrder/cases/", "$TEST_DATA_DIR_PATH/multiModuleOrder/out/") {
private val testGroupDir = "multiModuleOrder/"
private val pathToTestGroupDir = BasicBoxTest.TEST_DATA_DIR_PATH + testGroupDir
class MultiModuleOrderTest : BasicBoxTest(pathToTestGroupDir, testGroupDir) {
fun testPlain() {
runTest("plain")
}
@@ -31,7 +34,7 @@ class MultiModuleOrderTest : BasicBoxTest("$TEST_DATA_DIR_PATH/multiModuleOrder/
}
fun runTest(name: String) {
val fullPath = "$TEST_DATA_DIR_PATH/multiModuleOrder/cases/$name.kt"
val fullPath = pathToTestGroupDir + "$name.kt"
doTest(fullPath)
checkWrongOrderReported(fullPath, name)
}
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.js.test.BasicBoxTest
abstract class BorrowedInlineTest(relativePath: String) : BasicBoxTest(
"compiler/testData/codegen/boxInline/$relativePath",
"${BasicBoxTest.TEST_DATA_DIR_PATH}/out/codegen/boxInline/$relativePath/"
"codegen/boxInline/$relativePath"
) {
init {
additionalCommonFileDirectories += BasicBoxTest.TEST_DATA_DIR_PATH + relativePath + "/_commonFiles/"
@@ -41,25 +41,25 @@ abstract class AbstractInlineDefaultValuesTests : BorrowedInlineTest("defaultVal
abstract class AbstractBoxJsTest : BasicBoxTest(
BasicBoxTest.TEST_DATA_DIR_PATH + "box/",
BasicBoxTest.TEST_DATA_DIR_PATH + "out/box/"
"box/"
) {
override val runMinifierByDefault: Boolean = true
}
abstract class AbstractJsCodegenBoxTest : BasicBoxTest(
"compiler/testData/codegen/box/",
BasicBoxTest.TEST_DATA_DIR_PATH + "out/codegen/box/"
"codegen/box/"
)
abstract class AbstractJsLegacyPrimitiveArraysBoxTest : BasicBoxTest(
"compiler/testData/codegen/box/arrays/",
BasicBoxTest.TEST_DATA_DIR_PATH + "out/codegen/box/arrays-legacy-primitivearrays/",
"codegen/box/arrays-legacy-primitivearrays/",
typedArraysEnabled = false
)
abstract class AbstractSourceMapGenerationSmokeTest : BasicBoxTest(
BasicBoxTest.TEST_DATA_DIR_PATH + "sourcemap/",
"${BasicBoxTest.TEST_DATA_DIR_PATH}/out/sourcemap/",
"sourcemap/",
generateSourceMap = true,
generateNodeJsRunner = false
)