Scripting: fix string script source location
fixes proper script definition discovery for expressions and other scripts created from a string.
This commit is contained in:
committed by
Space Team
parent
f420b6c709
commit
0d7a5c6b1b
@@ -108,7 +108,7 @@ open class StringScriptSource(val source: String, override val name: String? = n
|
|||||||
|
|
||||||
override val text: String get() = source
|
override val text: String get() = source
|
||||||
|
|
||||||
override val locationId: String? = null
|
override val locationId: String? get() = name
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean =
|
override fun equals(other: Any?): Boolean =
|
||||||
this === other || (other as? StringScriptSource)?.let { text == it.text && name == it.name && locationId == it.locationId } == true
|
this === other || (other as? StringScriptSource)?.let { text == it.text && name == it.name && locationId == it.locationId } == true
|
||||||
|
|||||||
+3
-11
@@ -71,28 +71,20 @@ class ScriptingWithCliCompilerTest {
|
|||||||
runWithK2JVMCompiler(
|
runWithK2JVMCompiler(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"-cp", getMainKtsClassPath().joinToString(File.pathSeparator),
|
"-cp", getMainKtsClassPath().joinToString(File.pathSeparator),
|
||||||
"-expression",
|
"-expression=@file:CompilerOptions(\"-Xunknown1\")"
|
||||||
"\\@file:CompilerOptions(\"-Xunknown1\")"
|
|
||||||
),
|
),
|
||||||
expectedExitCode = 1,
|
expectedExitCode = 1,
|
||||||
expectedSomeErrPatterns = listOf(
|
expectedSomeErrPatterns = listOf(
|
||||||
"unresolved reference: CompilerOptions"
|
"unresolved reference: CompilerOptions"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
// it seems not possible to make a one-liner with the annotation, and
|
|
||||||
// annotation is the easiest available distinguishing factor for the .main.kts script
|
|
||||||
// so, considering "expecting an element" error as a success here
|
|
||||||
runWithK2JVMCompiler(
|
runWithK2JVMCompiler(
|
||||||
arrayOf(
|
arrayOf(
|
||||||
"-cp", getMainKtsClassPath().joinToString(File.pathSeparator),
|
"-cp", getMainKtsClassPath().joinToString(File.pathSeparator),
|
||||||
"-Xdefault-script-extension=.main.kts",
|
"-Xdefault-script-extension=.main.kts",
|
||||||
"-expression",
|
"-expression=@file:CompilerOptions(\"-Xunknown1\")"
|
||||||
"\\@file:CompilerOptions(\"-Xunknown1\")"
|
|
||||||
),
|
),
|
||||||
expectedExitCode = 1,
|
expectedExitCode = 0,
|
||||||
expectedSomeErrPatterns = listOf(
|
|
||||||
"expecting an element"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user