Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889#!/bin/bashset -euo pipefailcd "$(dirname "$0")/.."[[ $# -eq 0 ]] || { printf 'Usage: %s\n' "$0" >&2; exit 2; }process_status=0pgrep -x Parcel > /dev/null || process_status=$?case "$process_status" in 0) printf 'Quit your running Parcel first; leaks only inspects the soak harness-owned app.\n' >&2; exit 2 ;; 1) ;; *) printf 'Could not inspect running Parcel processes.\n' >&2; exit "$process_status" ;;esacmkdir -p build/leakswork=$(mktemp -d "$PWD/build/leaks/run.XXXXXX")runner_pid=finish_runner() { local deadline=$((SECONDS + 130)) while kill -0 "$runner_pid" 2>/dev/null; do if (( SECONDS >= deadline )); then printf 'Harness failed to exit after continuation; terminating only the owned runner.\n' >&2 kill -TERM "$runner_pid" 2>/dev/null || true deadline=$((SECONDS + 5)) while kill -0 "$runner_pid" 2>/dev/null && (( SECONDS < deadline )); do sleep 0.5; done if kill -0 "$runner_pid" 2>/dev/null; then kill -KILL "$runner_pid" 2>/dev/null || true; fi wait "$runner_pid" || true return 2 fi sleep 0.5 done wait "$runner_pid"}cleanup() { # Release the harness on tool failure as well as success; the harness owns app cleanup. touch "$work/continue" if [[ -n $runner_pid ]]; then finish_runner || true; fi}trap cleanup EXITwait_seconds=${PARCEL_LEAK_WAIT_SECONDS:-1800}[[ $wait_seconds =~ ^[0-9]+$ ]] || { printf 'PARCEL_LEAK_WAIT_SECONDS must be nonnegative seconds.\n' >&2; exit 2; }wait_seconds=$((10#$wait_seconds))MallocStackLogging=1 PARCEL_SOAK=1 PARCEL_E2E_INSPECTABLE=1 \ PARCEL_E2E_FILTER='ParcelE2ETests.*SoakTests' \ PARCEL_LEAK_PID_FILE="$work/pid" PARCEL_LEAK_CONTINUE_FILE="$work/continue" \ Scripts/test-e2e.sh debug > "$work/soak.log" 2>&1 &runner_pid=$!started=$SECONDSwhile [[ ! -s $work/pid ]]; do if ! kill -0 "$runner_pid" 2>/dev/null; then status=0 wait "$runner_pid" || status=$? runner_pid= printf 'Soak exited before its leak handshake (status %s); inspect %s/soak.log.\n' "$status" "$work" >&2 exit 2 fi if (( SECONDS - started >= wait_seconds )); then printf 'Timed out waiting for the soak leak handshake; inspect %s/soak.log.\n' "$work" >&2 exit 2 fi sleep 0.5done[[ ! -L $work/pid ]] || { printf 'Leak PID file must not be a symlink.\n' >&2; exit 2; }IFS= read -r pid < "$work/pid"[[ $pid =~ ^[1-9][0-9]*$ ]] || { printf 'Invalid harness-owned PID.\n' >&2; exit 2; }process=$(ps -p "$pid" -o comm=)expected="$(pwd -P)/build/Parcel.app/Contents/MacOS/Parcel"[[ $process == "$expected" ]] || { printf 'Handshake PID does not identify the harness bundle executable.\n' >&2; exit 2; }codesign -d --entitlements :- build/Parcel.app > "$work/entitlements.plist" 2> "$work/codesign.stderr"Scripts/parcel-dev.sh inspectable-entitlements "$work/entitlements.plist" || { printf 'Leak inspection requires the explicitly inspectable debug bundle.\n' >&2 exit 2}status=0# Report files intentionally belong to the invoking user, not root.# shellcheck disable=SC2024sudo -n /usr/bin/leaks --outputGraph="$work/parcel.memgraph" "$pid" > "$work/leaks.txt" 2> "$work/leaks.stderr" || status=$?touch "$work/continue"soak_status=0finish_runner || soak_status=$?runner_pid=if (( status != 0 )); then printf 'leaks failed or found leaks (status %s); inspect %s.\n' "$status" "$work" >&2 exit "$status"fiif (( soak_status != 0 )); then printf 'Soak failed (status %s); inspect %s/soak.log.\n' "$soak_status" "$work" >&2 exit "$soak_status"fi[[ -f $work/parcel.memgraph ]] || { printf 'leaks did not write its requested memory graph.\n' >&2; exit 2; }printf 'Harness-owned debug leak report: %s\n' "$work"