Repository navigation
Expand file tree
/
Copy pathrun-gates.sh
More file actions
executable file
·53 lines (48 loc) · 1.95 KB
/
Copy pathrun-gates.sh
File metadata and controls
executable file
·53 lines (48 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# Runs both required test gates against the freshly-built vendor/sharp addon.
# Exits non-zero if either gate fails, so this is usable as a CI check.
set -uo pipefail
cd "$(dirname "$0")/.."
ROOT="$PWD"
echo "=== Gate 1: sharp's own upstream test suite (under plain Node) ==="
GATE1_LOG=$(mktemp)
docker run --rm \
-v "$ROOT:$ROOT" \
-w "$ROOT/vendor/sharp" \
-e LD_LIBRARY_PATH="$ROOT/dist/linux-x64/lib" \
sharp-electron-build sh -c "node --experimental-test-coverage test/unit.mjs" > "$GATE1_LOG" 2>&1
gate1_exit=$?
# test/unit/esm.mjs is a known, pre-existing, unrelated failure (an
# ERR_REQUIRE_ESM CJS/ESM interop quirk on this Node version — present against
# a stock, unpatched sharp build too). Anything else failing is a real gate-1
# failure.
other_failures=$(grep -E "^not ok" "$GATE1_LOG" | grep -v "esm.mjs" || true)
if [ -n "$other_failures" ]; then
echo "GATE 1 FAILED — failures beyond the known esm.mjs interop quirk:"
echo "$other_failures"
tail -60 "$GATE1_LOG"
rm -f "$GATE1_LOG"
exit 1
fi
tail -15 "$GATE1_LOG"
rm -f "$GATE1_LOG"
echo "GATE 1 PASSED (esm.mjs failure, if any, is the known unrelated quirk)"
echo ""
echo "=== Gate 2: Electron crash repro against the rebuilt addon (the gate that matters) ==="
# ELECTRON_DISABLE_SANDBOX: defensive, for CI containers that lack the
# setuid sandbox helper's usual permissions. ELECTRON_RUN_AS_NODE already
# means no browser/renderer process gets spawned, so this shouldn't be
# load-bearing locally, but costs nothing to set.
SHARP_MODULE_PATH="$ROOT/vendor/sharp/dist/index.cjs" \
ELECTRON_RUN_AS_NODE=1 \
ELECTRON_DISABLE_SANDBOX=1 \
LD_LIBRARY_PATH="$ROOT/dist/linux-x64/lib" \
./node_modules/.bin/electron test/electron-crash-repro.js
gate2_exit=$?
if [ "$gate2_exit" -ne 0 ]; then
echo "GATE 2 FAILED (exit $gate2_exit) — see README.md's 'Test gates' section for the wrapper-set-expansion loop"
exit 1
fi
echo "GATE 2 PASSED"
echo ""
echo "Both gates passed."