|
1 | | -#!/usr/bin/env bash |
2 | | -set -euo pipefail |
| 1 | +#!/usr/bin/env bash -O globstar -O extglob |
3 | 2 |
|
4 | | -root="$(cd "$(dirname "$0")/.." && pwd)" |
| 3 | +# Assume that acp.el and shell-maker are checked out in sibling trunk |
| 4 | +# worktrees and allow their location to be overridden: |
| 5 | +# …/agent-shell/main/bin/test |
| 6 | +# …/acp.el/main |
| 7 | +# …/shell-maker/main |
| 8 | +root=$(dirname "$0")/.. |
| 9 | +tests_dir=${root}/tests |
| 10 | +acp_root=${acp_root:-${root}/../../acp.el/main} |
| 11 | +shell_maker_root=${shell_maker_root:-${root}/../../shell-maker/main} |
5 | 12 |
|
6 | | -: "${shell_maker_checkout:?Set shell_maker_checkout to your shell-maker checkout (e.g. ~/git/xenodium/shell-maker/main)}" |
7 | | -: "${acp_checkout:?Set acp_checkout to your acp.el checkout (e.g. ~/git/timvisher-dd/acp.el/dev)}" |
| 13 | +if ! [[ -r ${acp_root}/acp.el ]] |
| 14 | +then |
| 15 | + echo "Set shell_maker_root to your shell-maker checkout (e.g. ~/git/xenodium/shell-maker/main)" >&2 |
| 16 | + die=1 |
| 17 | +fi |
8 | 18 |
|
9 | | -test_files=() |
10 | | -for f in "$root"/tests/*-tests.el; do |
11 | | - test_files+=(-l "$f") |
| 19 | +if ! [[ -r ${shell_maker_root}/shell-maker.el ]] |
| 20 | +then |
| 21 | + echo "Set shell_maker_root to your shell-maker checkout (e.g. ~/git/xenodium/shell-maker/main)" >&2 |
| 22 | + die=1 |
| 23 | +fi |
| 24 | + |
| 25 | +if [[ -n $die ]] |
| 26 | +then |
| 27 | + echo "Fix the ↑ problems" >&2 |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | + |
| 31 | +shopt -s nullglob |
| 32 | +all_elc_files=({"${root}","${acp_root}","${shell_maker_root}"}/**/*.elc) |
| 33 | +all_el_files=("${root}"/*.el) |
| 34 | +test_files=("${tests_dir}"/*-tests.el) |
| 35 | +shopt -u nullglob |
| 36 | + |
| 37 | +if (( 0 < ${#all_elc_files[@]} )) |
| 38 | +then |
| 39 | + rm -v "${all_elc_files[@]}" |
| 40 | +fi |
| 41 | + |
| 42 | +# Filter out x./y./z. prefixed scratch files from compilation |
| 43 | +compile_files=() |
| 44 | +for f in "${all_el_files[@]}"; do |
| 45 | + case "$(basename "$f")" in |
| 46 | + x.*|y.*|z.*) ;; |
| 47 | + *) compile_files+=("$f") ;; |
| 48 | + esac |
12 | 49 | done |
13 | 50 |
|
14 | | -exec emacs --batch -Q \ |
15 | | - --eval "(setq load-prefer-newer 't)" \ |
16 | | - -L "$root" \ |
17 | | - -L "$root/tests" \ |
18 | | - -L "$shell_maker_checkout" \ |
19 | | - -L "$acp_checkout" \ |
20 | | - "${test_files[@]}" \ |
| 51 | +if (( ${#compile_files[@]} < 1 )); then |
| 52 | + echo "No compile targets found in ${root}" >&2 |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | + |
| 56 | +if (( ${#test_files[@]} < 1 )); then |
| 57 | + echo "No test files found in ${tests_dir}" >&2 |
| 58 | + exit 1 |
| 59 | +fi |
| 60 | + |
| 61 | +test_args=() |
| 62 | +for file in "${test_files[@]}"; do |
| 63 | + test_args+=(-l "$file") |
| 64 | +done |
| 65 | + |
| 66 | +emacs -Q --batch \ |
| 67 | + -L "${root}" \ |
| 68 | + -L "${acp_root}" \ |
| 69 | + -L "${shell_maker_root}" \ |
| 70 | + -f batch-byte-compile \ |
| 71 | + "${compile_files[@]}" |
| 72 | + |
| 73 | +emacs -Q --batch \ |
| 74 | + -L "${root}" \ |
| 75 | + -L "${acp_root}" \ |
| 76 | + -L "${shell_maker_root}" \ |
| 77 | + -L "${tests_dir}" \ |
| 78 | + "${test_args[@]}" \ |
21 | 79 | -f ert-run-tests-batch-and-exit |
0 commit comments