[minor] Fix classpath from class calculation utility for classes dir
This commit is contained in:
+8
@@ -15,6 +15,7 @@ import java.util.jar.JarEntry
|
||||
import java.util.jar.JarOutputStream
|
||||
import java.util.jar.Manifest
|
||||
import kotlin.script.experimental.jvm.util.classPathFromTypicalResourceUrls
|
||||
import kotlin.script.experimental.jvm.util.classpathFromClass
|
||||
import kotlin.script.experimental.jvm.util.classpathFromClassloader
|
||||
import kotlin.script.experimental.jvm.util.scriptCompilationClasspathFromContextOrNull
|
||||
|
||||
@@ -80,6 +81,13 @@ class ClassPathTest : TestCase() {
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClasspathFromClass() {
|
||||
val cpFromThis = classpathFromClass(this::class)
|
||||
val expectedSuffix = "classes/kotlin/test"
|
||||
assertTrue("Path should end with $expectedSuffix, got: $cpFromThis", cpFromThis!!.first().path.endsWith(expectedSuffix))
|
||||
}
|
||||
}
|
||||
|
||||
private val emulatedCollectionFiles = arrayOf(
|
||||
|
||||
@@ -118,7 +118,7 @@ internal fun ClassLoader.rawClassPathFromKeyResourcePath(keyResourcePath: String
|
||||
keyResourcePathDepth = keyResourcePath.trim('/').count { it == '/' }
|
||||
}
|
||||
var root = file
|
||||
for (i in 1..keyResourcePathDepth) {
|
||||
for (i in 0..keyResourcePathDepth) {
|
||||
root = root.parentFile
|
||||
}
|
||||
root
|
||||
|
||||
Reference in New Issue
Block a user