Commit 23603d1a authored by Drew's avatar Drew

Fix import paths for deeply-imported packages

Use the task's package's import path, since the import path of a task
may be different than the path of the package we imported it from.  This
is the case for a->b->c, since a imports task c via b, but the import
path should be that of c.

Add test coverage
parent 9b01fe07
Pipeline #902 passed with stage
......@@ -292,7 +292,7 @@ final public class Package {
//load remote tasks
for remotePackage in remotePackages {
for (_, task) in remotePackage.tasks {
task.importedPath = remotePackage.adjustedImportPath
task.importedPath = task.package.adjustedImportPath
self.tasks[task.qualifiedName] = task
}
}
......
(package
:name "a"
:import ["b/b.atpkg"]
:tasks {
:default {
:dependencies ["b.default"]
:name "a_default"
}
}
)
\ No newline at end of file
(package
:name "b"
:import ["c/c.atpkg"]
:tasks {
:foo {
}
:default {
:dependencies ["c.default" "foo"]
:name "b_default"
}
}
)
\ No newline at end of file
(package
:name "c"
:tasks {
:default {
:name "c_default"
}
}
)
\ No newline at end of file
......@@ -23,7 +23,8 @@ class PackageTests: Test {
PackageTests.testImport,
PackageTests.testOverlays,
PackageTests.testExportedOverlays,
PackageTests.testChainedImports
PackageTests.testChainedImports,
PackageTests.testImportPaths
]
let filename = __FILE__
......@@ -166,4 +167,39 @@ class PackageTests: Test {
let _ = package.prunedDependencyGraph(a_default_unqualified)
}
static func testImportPaths () throws {
let filepath = "./tests/collateral/import_paths/a.atpkg"
guard let package = Package(filepath: filepath, overlay: []) else { print("error"); try test.assert(false); return }
guard let a_default_unqualified = package.tasks["default"] else {
fatalError("No default task")
}
try test.assert(a_default_unqualified["name"]?.string == "a_default")
guard let a_default_qualified = package.tasks["a.default"] else {
fatalError("No default task (qualified)")
}
try test.assert(a_default_qualified["name"]?.string == "a_default")
guard let b_default_qualified = package.tasks["b.default"] else {
fatalError("No default task in b")
}
try test.assert(b_default_qualified["name"]?.string == "b_default")
guard let c_default_qualified = package.tasks["c.default"] else {
fatalError("No default task in c")
}
try test.assert(c_default_qualified["name"]?.string == "c_default")
//check package dependency graph
let _ = package.prunedDependencyGraph(a_default_unqualified)
//check each import path
try test.assert(a_default_unqualified.importedPath == "./tests/collateral/import_paths/")
try test.assert(a_default_qualified.importedPath == "./tests/collateral/import_paths/")
try test.assert(b_default_qualified.importedPath == "./tests/collateral/import_paths/b/")
try test.assert(c_default_qualified.importedPath == "./tests/collateral/import_paths/b/c/")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment