rg (ripgrep 15.2), grep (ours, on ripgrep's regex crates), find and xargs (ours), sed (uutils 0.3 wrapper), diff and cmp (uutils diffutils 0.6 with -r), fd 10.5, jaq 2.3, env and timeout. userland/spawn is a small Command-like client of the process interface. search-test.nu: 42 cases match native tools.
19 lines
1.1 KiB
Nu
19 lines
1.1 KiB
Nu
# Keep the full WIT output as evidence, then check every declared import.
|
|
def main [] {
|
|
let repo = ($env.FILE_PWD | path dirname | path dirname)
|
|
let artifacts = ($repo | path join userland target tools wasm32-wasip2 release)
|
|
let evidence = (^mktemp -d --tmpdir=/tmp t14-imports.XXXXXXXX)
|
|
for tool in [rg grep find xargs sed diffutils fd jaq env timeout] {
|
|
let wasm = ($artifacts | path join $"($tool).wasm")
|
|
let wit = (^wasm-tools component wit $wasm)
|
|
$wit | save ($evidence | path join $"($tool).wit")
|
|
let imports = ($wit | lines | where {|line| $line | str starts-with ' import ' })
|
|
for import in $imports {
|
|
let allowed = ($import | str starts-with ' import wasi:') or (($tool in [find xargs env timeout]) and ($import | str starts-with ' import sausage:process/host@0.1.0;'))
|
|
if not $allowed { error make {msg: $"Unexpected import: ($tool): ($import)"} }
|
|
}
|
|
print $"PASS imports ($tool): ((ls $wasm | get size | first | into int)) bytes"
|
|
}
|
|
print $"Full WIT evidence: ($evidence)"
|
|
}
|