fix tests
This commit is contained in:
@@ -2288,6 +2288,52 @@ Shop.load_as_dylib = function(path, pkg) {
|
||||
return os.native_module_load_named(result._handle, result._sym, env)
|
||||
}
|
||||
|
||||
// Trace all transitive module dependencies for a file.
|
||||
// Returns {scripts: [{path, package}], c_packages: [string]}
|
||||
Shop.trace_deps = function(file_path) {
|
||||
var visited = {}
|
||||
var scripts = []
|
||||
var c_packages = {}
|
||||
|
||||
function trace(fp) {
|
||||
if (visited[fp]) return
|
||||
visited[fp] = true
|
||||
var fi = Shop.file_info(fp)
|
||||
var file_pkg = fi.package
|
||||
var idx = null
|
||||
var j = 0
|
||||
var imp = null
|
||||
var rinfo = null
|
||||
if (ends_with(fp, '.cm'))
|
||||
scripts[] = {path: fp, package: file_pkg}
|
||||
var _trace = function() {
|
||||
idx = Shop.index_file(fp)
|
||||
if (!idx || !idx.imports) return
|
||||
j = 0
|
||||
while (j < length(idx.imports)) {
|
||||
imp = idx.imports[j]
|
||||
rinfo = Shop.resolve_import_info(imp.module_path, file_pkg)
|
||||
if (rinfo) {
|
||||
if (rinfo.type == 'script' && rinfo.resolved_path)
|
||||
trace(rinfo.resolved_path)
|
||||
else if (rinfo.type == 'native' && rinfo.package)
|
||||
c_packages[rinfo.package] = true
|
||||
}
|
||||
j = j + 1
|
||||
}
|
||||
} disruption {}
|
||||
_trace()
|
||||
}
|
||||
|
||||
trace(file_path)
|
||||
return {scripts: scripts, c_packages: array(c_packages)}
|
||||
}
|
||||
|
||||
// Check if a C package has a build manifest (was previously built)
|
||||
Shop.has_c_manifest = function(pkg) {
|
||||
return fd.is_file(dylib_manifest_path(pkg))
|
||||
}
|
||||
|
||||
// Check if a .cm file has a cached bytecode artifact (mach or mcode)
|
||||
Shop.is_cached = function(path) {
|
||||
if (!fd.is_file(path)) return false
|
||||
|
||||
Reference in New Issue
Block a user