This commit is contained in:
@@ -96,11 +96,8 @@
|
|||||||
# Exercise the installed host exactly as the loop launches it: the
|
# Exercise the installed host exactly as the loop launches it: the
|
||||||
# caller has no Cargo on PATH, so only the packaged runtime toolchain
|
# caller has no Cargo on PATH, so only the packaged runtime toolchain
|
||||||
# can run the native tests and the wasm32-wasip2 build.
|
# can run the native tests and the wasm32-wasip2 build.
|
||||||
checks.runtime-toolchain = pkgs.runCommand "sausage-runtime-toolchain" {
|
checks.runtime-toolchain = pkgs.runCommand "sausage-runtime-toolchain" { } ''
|
||||||
nativeBuildInputs = [ pkgs.expect ];
|
set -eu
|
||||||
} ''
|
|
||||||
set -eux
|
|
||||||
echo "runtime-check: prepare fixture"
|
|
||||||
root="$TMPDIR/runtime-toolchain"
|
root="$TMPDIR/runtime-toolchain"
|
||||||
world="$root/world"
|
world="$root/world"
|
||||||
emptyPath="$root/empty-bin"
|
emptyPath="$root/empty-bin"
|
||||||
@@ -123,37 +120,39 @@
|
|||||||
assert_eq!(2 + 2, 4);
|
assert_eq!(2 + 2, 4);
|
||||||
}
|
}
|
||||||
RUST
|
RUST
|
||||||
export SAUSAGE_BIN=${sausage}/bin/sausage
|
echo "runtime-check: run packaged host with an empty PATH"
|
||||||
export WORLD="$world"
|
coproc host {
|
||||||
export EMPTY_PATH="$emptyPath"
|
${pkgs.coreutils}/bin/env -i PATH="$emptyPath" HOME="$root/home" TMPDIR="$root" \
|
||||||
echo "runtime-check: start expect with empty PATH"
|
CARGO_HOME="$root/cargo-home" ${sausage}/bin/sausage run "$world"
|
||||||
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 }
|
|
||||||
}
|
}
|
||||||
expect eof
|
hostInput=''${host[1]}
|
||||||
set result [wait]
|
hostOutput=''${host[0]}
|
||||||
if {[lindex $result 3] != 0} { exit [lindex $result 3] }
|
hostPid=$host_PID
|
||||||
EOF
|
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"
|
mkdir -p "$out"
|
||||||
touch "$out/passed"
|
touch "$out/passed"
|
||||||
'';
|
'';
|
||||||
|
|||||||
Reference in New Issue
Block a user