Fix evaluating dependency notation URIs with multiple file output (#1942)
This commit is contained in:
1 parent
434f699887
commit
ea68f7b258
10 files changed
+89
-12
No files matched your search
@@ -123,18 +123,23 @@ constructor(
|
||||
|
||||
return options.base.normalizedSourceModules.associateWith { uri ->
|
||||
val moduleDir: String? =
|
||||
IoUtils.toPath(uri)?.let {
|
||||
IoUtils.relativize(it.parent, workingDir).toString().ifEmpty { "." }
|
||||
}
|
||||
val moduleKey =
|
||||
try {
|
||||
moduleResolver.resolve(uri)
|
||||
} catch (e: VmException) {
|
||||
throw e.toPklException(stackFrameTransformer, options.base.color?.hasColor() ?: false)
|
||||
}
|
||||
if (!uri.isAbsolute && uri.schemeSpecificPart.startsWith("@")) null
|
||||
else
|
||||
IoUtils.toPath(uri)?.let {
|
||||
IoUtils.relativize(it.parent, workingDir).toString().ifEmpty { "." }
|
||||
}
|
||||
val moduleName =
|
||||
if (!uri.isAbsolute && uri.schemeSpecificPart.startsWith("@"))
|
||||
IoUtils.getNameWithoutExtension(uri.path)
|
||||
else
|
||||
try {
|
||||
IoUtils.inferModuleName(moduleResolver.resolve(uri))
|
||||
} catch (e: VmException) {
|
||||
throw e.toPklException(stackFrameTransformer, options.base.color?.hasColor() ?: false)
|
||||
}
|
||||
val substituted =
|
||||
pathStr
|
||||
.replace("%{moduleName}", IoUtils.inferModuleName(moduleKey))
|
||||
.replace("%{moduleName}", moduleName)
|
||||
.replace("%{outputFormat}", options.outputFormat ?: "%{outputFormat}")
|
||||
.replace("%{moduleDir}", moduleDir ?: "%{moduleDir}")
|
||||
if (substituted.contains("%{moduleDir}")) {
|
||||
|
||||
@@ -1798,6 +1798,31 @@ result = someLib.x
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `eval dependency notation source with multiple file output`(
|
||||
@TempDir tempDir: Path,
|
||||
@TempDir cacheDir: Path,
|
||||
) {
|
||||
PackageServer.populateCacheDir(cacheDir)
|
||||
val projectPath =
|
||||
FileTestUtils.rootProjectDir.resolve(
|
||||
"pkl-commons-cli/src/test/resources/org/pkl/commons/cli/project1/"
|
||||
)
|
||||
val options =
|
||||
CliEvaluatorOptions(
|
||||
CliBaseOptions(
|
||||
sourceModules = listOf(URI("@fruit/catalog/basket.pkl")),
|
||||
projectDir = projectPath,
|
||||
moduleCacheDir = cacheDir,
|
||||
workingDir = tempDir,
|
||||
),
|
||||
multipleFileOutputPath = "output",
|
||||
)
|
||||
val output = evalToConsole(options)
|
||||
assertThat(output.split('\n')).hasSize(3)
|
||||
assertThat(tempDir.resolve("output").listDirectoryEntries()).hasSize(2)
|
||||
}
|
||||
|
||||
private fun evalModuleThatImportsPackage(certsFile: Path?, testPort: Int = -1) {
|
||||
val moduleUri =
|
||||
writePklFile(
|
||||
|
||||
Reference in new issue
Block a user