JS DCE: drop unknown file report severity to WARNING
*.kjsm and other files might be received when FileCollection is
used in Gradle as a dependency.
Example: `testCompile project(":$coroutines_core").sourceSets.test.output`
(a popular-ish solution to introduce dependencies between tests)
This commit is contained in:
@@ -33,18 +33,11 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
||||
|
||||
override fun execImpl(messageCollector: MessageCollector, services: Services, arguments: K2JSDceArguments): ExitCode {
|
||||
val baseDir = File(arguments.outputDirectory ?: "min")
|
||||
var hasErrors = false
|
||||
val files = arguments.freeArgs.flatMap { arg ->
|
||||
val files = collectInputFiles(baseDir, arg, messageCollector)
|
||||
if (files != null) {
|
||||
files
|
||||
} else {
|
||||
hasErrors = true
|
||||
emptyList()
|
||||
}
|
||||
collectInputFiles(baseDir, arg, messageCollector)
|
||||
}
|
||||
|
||||
if (hasErrors) return ExitCode.COMPILATION_ERROR
|
||||
if (messageCollector.hasErrors()) return ExitCode.COMPILATION_ERROR
|
||||
|
||||
if (files.isEmpty() && !arguments.version) {
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, "no source files")
|
||||
@@ -163,7 +156,7 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
||||
return true
|
||||
}
|
||||
|
||||
private fun collectInputFiles(baseDir: File, fileName: String, messageCollector: MessageCollector): List<InputFile>? {
|
||||
private fun collectInputFiles(baseDir: File, fileName: String, messageCollector: MessageCollector): List<InputFile> {
|
||||
val file = File(fileName)
|
||||
return when {
|
||||
file.isDirectory -> {
|
||||
@@ -179,16 +172,16 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
||||
}
|
||||
else -> {
|
||||
messageCollector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"invalid file name '$fileName'; must end either with '.js', '.zip' or '.jar'"
|
||||
CompilerMessageSeverity.WARNING,
|
||||
"invalid file name '${file.absolutePath}'; must end either with '.js', '.zip' or '.jar'"
|
||||
)
|
||||
null
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, "source file or directory not found: $fileName")
|
||||
null
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
$TESTDATA_DIR$/invalidFilename.args
|
||||
$TESTDATA_DIR$/simple.js
|
||||
-output-dir
|
||||
$TEMP_DIR$/min
|
||||
@@ -0,0 +1,2 @@
|
||||
warning: invalid file name '$TESTDATA_DIR$/invalidFilename.args'; must end either with '.js', '.zip' or '.jar'
|
||||
OK
|
||||
@@ -0,0 +1 @@
|
||||
// EXISTS: min/simple.js
|
||||
@@ -783,6 +783,12 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
doJsDceTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("invalidFilename.args")
|
||||
public void testInvalidFilename() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js-dce/invalidFilename.args");
|
||||
doJsDceTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("jsExtraHelp.args")
|
||||
public void testJsExtraHelp() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/js-dce/jsExtraHelp.args");
|
||||
|
||||
+21
@@ -279,6 +279,27 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDceFileCollectionDependency() {
|
||||
val project = Project("kotlin2JsDceProject", "2.10", minLogLevel = LogLevel.INFO)
|
||||
|
||||
project.setupWorkingDir()
|
||||
File(project.projectDir, "mainProject/build.gradle").modify {
|
||||
it.replace("compile project(\":libraryProject\")", "compile project(\":libraryProject\").sourceSets.main.output")
|
||||
}
|
||||
|
||||
project.build("runRhino") {
|
||||
assertSuccessful()
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/main"
|
||||
assertFileExists("$pathPrefix/exampleapp.js.map")
|
||||
assertFileExists("$pathPrefix/examplelib.js.map")
|
||||
assertFileContains("$pathPrefix/exampleapp.js.map", "\"../../../src/main/kotlin/exampleapp/main.kt\"")
|
||||
|
||||
assertFileExists("$pathPrefix/kotlin.js")
|
||||
assertTrue(fileInWorkingDir("$pathPrefix/kotlin.js").length() < 500 * 1000, "Looks like kotlin.js file was not minified by DCE")
|
||||
}
|
||||
}
|
||||
|
||||
/** Issue: KT-18495 */
|
||||
@Test
|
||||
fun testNoSeparateClassesDirWarning() {
|
||||
|
||||
Reference in New Issue
Block a user