This commit is contained in:
@@ -96,11 +96,8 @@
|
||||
# Exercise the installed host exactly as the loop launches it: the
|
||||
# caller has no Cargo on PATH, so only the packaged runtime toolchain
|
||||
# can run the native tests and the wasm32-wasip2 build.
|
||||
checks.runtime-toolchain = pkgs.runCommand "sausage-runtime-toolchain" {
|
||||
nativeBuildInputs = [ pkgs.expect ];
|
||||
} ''
|
||||
set -eux
|
||||
echo "runtime-check: prepare fixture"
|
||||
checks.runtime-toolchain = pkgs.runCommand "sausage-runtime-toolchain" { } ''
|
||||
set -eu
|
||||
root="$TMPDIR/runtime-toolchain"
|
||||
world="$root/world"
|
||||
emptyPath="$root/empty-bin"
|
||||
@@ -123,37 +120,39 @@
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
RUST
|
||||
export SAUSAGE_BIN=${sausage}/bin/sausage
|
||||
export WORLD="$world"
|
||||
export EMPTY_PATH="$emptyPath"
|
||||
echo "runtime-check: start expect with empty PATH"
|
||||
expect <<'EOF'
|
||||
log_user 1
|
||||
set timeout 300
|
||||
set env(PATH) $::env(EMPTY_PATH)
|
||||
set env(HOME) $::env(WORLD)
|
||||
set env(TMPDIR) [file dirname $::env(WORLD)]
|
||||
set env(CARGO_HOME) [file join [file dirname $::env(WORLD)] cargo-home]
|
||||
puts stderr "runtime-check: spawn packaged host"
|
||||
spawn $::env(SAUSAGE_BIN) run $::env(WORLD)
|
||||
send -- "@cargo {\"type\":\"build\",\"source\":\"/actor/console/public/probe\"}\r"
|
||||
expect {
|
||||
-re {"type":"build_failed"} {
|
||||
puts stderr "packaged cargo actor build failed with an empty caller PATH"
|
||||
exit 1
|
||||
}
|
||||
-re {"type":"built"} {
|
||||
expect {
|
||||
-re {"passed":1} { send -- "/quit\r" }
|
||||
timeout { puts stderr "native cargo test did not pass"; exit 1 }
|
||||
}
|
||||
}
|
||||
timeout { puts stderr "packaged host did not build the probe"; exit 1 }
|
||||
echo "runtime-check: run packaged host with an empty PATH"
|
||||
coproc host {
|
||||
${pkgs.coreutils}/bin/env -i PATH="$emptyPath" HOME="$root/home" TMPDIR="$root" \
|
||||
CARGO_HOME="$root/cargo-home" ${sausage}/bin/sausage run "$world"
|
||||
}
|
||||
expect eof
|
||||
set result [wait]
|
||||
if {[lindex $result 3] != 0} { exit [lindex $result 3] }
|
||||
EOF
|
||||
hostInput=''${host[1]}
|
||||
hostOutput=''${host[0]}
|
||||
hostPid=$host_PID
|
||||
trap 'kill "$hostPid" 2>/dev/null || true' EXIT
|
||||
printf '%s\n' '@cargo {"type":"build","source":"/actor/console/public/probe"}' >&"$hostInput"
|
||||
built=0
|
||||
while IFS= read -r -t 300 line <&"$hostOutput"; do
|
||||
echo "$line"
|
||||
case "$line" in
|
||||
*'"type":"build_failed"'*)
|
||||
echo "packaged cargo actor build failed with an empty caller PATH" >&2
|
||||
exit 1
|
||||
;;
|
||||
*'"type":"built"'*)
|
||||
case "$line" in
|
||||
*'"passed":1'*) built=1 ;;
|
||||
*) echo "native test did not pass" >&2; exit 1 ;;
|
||||
esac
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ "$built" -ne 1 ]; then
|
||||
echo "packaged host did not build the probe" >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' '/quit' >&"$hostInput"
|
||||
wait "$hostPid"
|
||||
mkdir -p "$out"
|
||||
touch "$out/passed"
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user