31 lines
1.3 KiB
Nu
31 lines
1.3 KiB
Nu
#!/usr/bin/env nu
|
|
# Verify the packaged host's toolchain and namespace builder outside the Nix sandbox.
|
|
def main [host: path = 'result/bin/sausage'] {
|
|
let host = ($host | path expand)
|
|
let temporary = (^mktemp -d -t sausage-packaged.XXXXXX | str trim)
|
|
let world = ($temporary | path join world)
|
|
print $'Fresh world: ($world)'
|
|
let initialized = (^$host init $world | complete)
|
|
print --no-newline $initialized.stdout
|
|
print --stderr --no-newline $initialized.stderr
|
|
if $initialized.exit_code != 0 { error make {msg: 'packaged host init failed'} }
|
|
let script = r#'set -e
|
|
mkdir -p /src/projects
|
|
cd /src/projects
|
|
cargo new packaged-probe --vcs none
|
|
printf 'fn main() { println!("packaged builder OK"); }\n' > packaged-probe/src/main.rs
|
|
cd packaged-probe
|
|
cargo build --release
|
|
./target/wasm32-wasip2/release/packaged-probe.wasm
|
|
'#
|
|
let result = (^$host sh $world -c $script | complete)
|
|
print --no-newline $result.stdout
|
|
print --stderr --no-newline $result.stderr
|
|
if $result.exit_code != 0 { error make {msg: 'packaged builder failed'} }
|
|
if not ($result.stdout | lines | any {|line| $line == 'packaged builder OK' }) {
|
|
error make {msg: 'compiled program did not produce its expected output'}
|
|
}
|
|
rm --recursive --force $temporary
|
|
print 'Packaged builder check passed.'
|
|
}
|