Skip to content
File

Blob: src/workerd/server/tests/python/python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.sh

bash47 lines
1#!/bin/bash
2# Test that when the python-abort-isolate-on-fatal-error autogate is enabled,
3# triggering a Python fatal error causes the workerd process to abort.
4 
5set -uo pipefail
6 
7WORKERD=$1
8CONFIG=$2
9PYODIDE_BUNDLE=$3
10WHEELS_DIR=$4
11 
12TEST_TMPDIR="${TEST_TMPDIR:-/tmp}"
13 
14# Pyodide bundle directory is the parent of the .capnp.bin file.
15BUNDLE_DIR=$(dirname "$PYODIDE_BUNDLE")
16 
17output=$("$WORKERD" test \
18 "$CONFIG" \
19 --experimental \
20 --compat-date=2000-01-01 \
21 --pyodide-bundle-disk-cache-dir "$BUNDLE_DIR" \
22 --pyodide-package-disk-cache-dir "$WHEELS_DIR" \
23 -dTEST_TMPDIR="$TEST_TMPDIR" 2>&1)
24exit_code=$?
25 
26echo "--- captured output ---" >&2
27echo "$output" >&2
28echo "--- end captured output ---" >&2
29 
30if [ "$exit_code" -eq 0 ]; then
31 echo "FAIL: expected nonzero exit code from abortIsolate" >&2
32 exit 1
33fi
34 
35if ! echo "$output" | grep -qF "abortIsolate() called, terminating process"; then
36 echo "FAIL: expected abortIsolate fatal message not found" >&2
37 exit 1
38fi
39 
40if ! echo "$output" | grep -qF "Python worker fatal error"; then
41 echo "FAIL: expected Python worker fatal error reason not found" >&2
42 exit 1
43fi
44 
45echo "Success"
46exit 0