|
| 1 | +#!/usr/bin/env bash |
| 2 | +# ───────────────────────────────────────────────────────────────────────────── |
| 3 | +# The query cases (tests/run.py), every language, answered by the INSTALLED packages. |
| 4 | +# |
| 5 | +# e2e-cases.sh <engines-dir> <platform> [tests/run.py args...] |
| 6 | +# |
| 7 | +# e2e-install.sh proves an install answers every verb on one case per language. That is a smoke test: 0.1.10 |
| 8 | +# passed it on Windows while 43 of the cases' 1,844 checks failed there — tests not linked through a file path, |
| 9 | +# an absolute file:line refused, any argument holding ' or " mangled on its way into Git Bash. None of it is |
| 10 | +# platform-specific code; all of it is how Windows writes paths and command lines. So the cases run here, from |
| 11 | +# this checkout's plugin scripts, with the engine and parser of the packages a user installs (AXIOMCODE_ENGINE), |
| 12 | +# souffle hidden as it is for a user. |
| 13 | +# |
| 14 | +# CODEGRAPH_TGZ is the packed @axiomcode/code-graph, as for e2e-install.sh. |
| 15 | +# ───────────────────────────────────────────────────────────────────────────── |
| 16 | +set -uo pipefail |
| 17 | + |
| 18 | +engines="${1:?usage: e2e-cases.sh <engines-dir> <platform> [tests/run.py args...]}"; platform="${2:?platform}"; shift 2 |
| 19 | +root="$(cd "$(dirname "$0")/../.." && pwd)" |
| 20 | +engines="$(cd "$engines" && pwd)" |
| 21 | +W="$(mktemp -d)"; SHADOW=""; trap 'rm -rf "$W" ${SHADOW:+"$SHADOW"}' EXIT |
| 22 | +fail() { echo "::error::e2e cases: $*"; exit 1; } |
| 23 | +[ -n "${CODEGRAPH_TGZ:-}" ] || fail "CODEGRAPH_TGZ is not set" |
| 24 | + |
| 25 | +version="$(node "$root/.github/scripts/version.mjs" get)" |
| 26 | +bash "$root/packaging/assemble-engine-package.sh" "$platform" "$version" "$engines" "$W/engine" >/dev/null \ |
| 27 | + || fail "the engine package did not assemble" |
| 28 | +mkdir -p "$W/tgz" "$W/proj" |
| 29 | +( cd "$W/engine" && npm pack --silent --pack-destination "$W/tgz" >/dev/null ) || fail "npm pack of the engine package failed" |
| 30 | +cp "$CODEGRAPH_TGZ" "$W/tgz/" || fail "no code-graph tarball at $CODEGRAPH_TGZ" |
| 31 | +( cd "$W/proj" && npm init -y >/dev/null && npm install --no-audit --no-fund --loglevel=error "$W"/tgz/*.tgz ) \ |
| 32 | + || fail "npm install of the packed tarballs failed" |
| 33 | +export AXIOMCODE_ENGINE="$W/proj/node_modules/@axiomcode/code-graph" |
| 34 | +[ -d "$AXIOMCODE_ENGINE/graph" ] || fail "the installed package has no graph/ at $AXIOMCODE_ENGINE" |
| 35 | + |
| 36 | +. "$root/graph/test/tools/hide-souffle.sh" |
| 37 | +py="$(command -v python3 || command -v python)" || fail "no python" |
| 38 | +# the bash a native program starts, as the CLI hands it on: on Windows a bare `bash` is System32's WSL launcher |
| 39 | +command -v cygpath >/dev/null 2>&1 && export AXIOMCODE_BASH="${AXIOMCODE_BASH:-$(cygpath -m "$BASH")}" |
| 40 | +# and Python in UTF-8, as every launcher of the product sets it (the dispatcher, find-python.js): some tests start a |
| 41 | +# verb's script directly, and an answer's → is not cp1252 |
| 42 | +export PYTHONUTF8=1 |
| 43 | +rc=0 |
| 44 | +PATH="$SANDBOX_PATH" "$py" "$root/tests/run.py" "$@" || rc=1 |
| 45 | +# what only Windows can show for real: its separators, its exec, its symlinks, its command lines |
| 46 | +for t in mixed_separators no_symlink no_exec windows_argv; do |
| 47 | + PATH="$SANDBOX_PATH" "$py" "$root/tests/$t.py" > "$W/$t.log" 2>&1 && echo "$t: $(tail -1 "$W/$t.log")" \ |
| 48 | + || { echo "::error::e2e cases: tests/$t.py failed"; tail -30 "$W/$t.log"; rc=1; } |
| 49 | +done |
| 50 | +exit $rc |
0 commit comments