Skip to content

Commit 4dfdb7b

Browse files
committed
test: add bash 3.2 CI matrix for awk fallback coverage
- Install bash 3.2 from source in the Docker test image - Add CI matrix that runs the full test suite under both bash 5 and bash 3.2 (via TEST_BASH env var passed to save/restore recipes) - Split benchmarks into a separate job (only needs to run once) - Fix --model regex capture group for bash 3.2 compat (store pattern in a variable — inline capture groups are a syntax error on 3.2) The bash 3.2 run exercises the awk fallback path in the state cache (no associative arrays), catching the field-offset regression from PR #14 where session_id/model/env were shifted by one field.
1 parent 8cb8032 commit 4dfdb7b

5 files changed

Lines changed: 47 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ permissions:
1313
jobs:
1414
test:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
bash: [bash, bash3.2]
20+
name: test (bash ${{ matrix.bash == 'bash' && '5' || '3.2' }})
1621
steps:
1722
- uses: actions/checkout@v4
1823
with:
@@ -24,14 +29,28 @@ jobs:
2429
- name: Run tests
2530
run: |
2631
mkdir -p test-results
27-
docker run --rm -v ${{ github.workspace }}/test-results:/tmp/test-results tmux-assistant-resurrect-test
32+
docker run --rm \
33+
-e TEST_BASH=${{ matrix.bash }} \
34+
-v ${{ github.workspace }}/test-results:/tmp/test-results \
35+
tmux-assistant-resurrect-test
2836
2937
- name: Publish test results
3038
uses: EnricoMi/publish-unit-test-result-action@v2
3139
if: always()
3240
with:
3341
files: test-results/junit.xml
3442
comment_mode: off
43+
check_name: tests (${{ matrix.bash == 'bash' && 'bash 5' || 'bash 3.2' }})
44+
45+
benchmark:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Build test image
53+
run: docker build -t tmux-assistant-resurrect-test -f test/Dockerfile .
3554

3655
- name: Prepare benchmark baseline
3756
run: |

justfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,13 @@ status:
370370
fi
371371

372372
# Manually trigger a save of current assistant sessions
373+
# TEST_BASH overrides the interpreter (e.g. bash3.2 for compat testing).
373374
save:
374-
@bash "{{repo_dir}}/scripts/save-assistant-sessions.sh"
375+
@"${TEST_BASH:-bash}" "{{repo_dir}}/scripts/save-assistant-sessions.sh"
375376

376377
# Manually trigger a restore of saved assistant sessions
377378
restore:
378-
@bash "{{repo_dir}}/scripts/restore-assistant-sessions.sh"
379+
@"${TEST_BASH:-bash}" "{{repo_dir}}/scripts/restore-assistant-sessions.sh"
379380

380381
# Clean up stale state files (from dead processes)
381382
clean:

scripts/save-assistant-sessions.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ resolve_pane_candidates() {
391391
fi
392392

393393
# Fallback: parse --model from CLI args if not in state file.
394-
if [ -z "$model" ] && [[ "$cand_args" =~ --model[=\ ]([^\ ]+) ]]; then
394+
# Regex stored in variable for bash 3.2 compat (inline capture groups fail).
395+
local _model_re='--model[= ]([^ ]+)'
396+
if [ -z "$model" ] && [[ "$cand_args" =~ $_model_re ]]; then
395397
model="${BASH_REMATCH[1]}"
396398
fi
397399

test/Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM ubuntu:24.04
22

33
ENV DEBIAN_FRONTEND=noninteractive
44

5-
# Core tools
5+
# Core tools + build deps for bash 3.2
66
RUN apt-get update && apt-get install -y \
77
tmux \
88
jq \
@@ -13,8 +13,20 @@ RUN apt-get update && apt-get install -y \
1313
nodejs \
1414
npm \
1515
python3 \
16+
gcc \
17+
make \
1618
&& rm -rf /var/lib/apt/lists/*
1719

20+
# Install bash 3.2 from source (macOS ships bash 3.2; needed for awk-fallback tests)
21+
RUN ARCH=$(uname -m) && \
22+
case "$ARCH" in x86_64) TRIPLE="x86_64-pc-linux-gnu";; aarch64) TRIPLE="aarch64-unknown-linux-gnu";; *) TRIPLE="$ARCH-pc-linux-gnu";; esac && \
23+
curl -sSfL https://ftp.gnu.org/gnu/bash/bash-3.2.tar.gz | tar xz -C /tmp \
24+
&& cd /tmp/bash-3.2 \
25+
&& ./configure --build="$TRIPLE" --prefix=/usr/local --without-bash-malloc >/dev/null 2>&1 \
26+
&& make -j"$(nproc)" >/dev/null 2>&1 \
27+
&& cp bash /usr/local/bin/bash3.2 \
28+
&& rm -rf /tmp/bash-3.2
29+
1830
# Install just
1931
RUN curl -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
2032

@@ -34,4 +46,8 @@ WORKDIR /home/testuser
3446
# Copy the repo in (done as testuser for correct ownership)
3547
COPY --chown=testuser:testuser . /home/testuser/tmux-assistant-resurrect
3648

37-
ENTRYPOINT ["bash", "/home/testuser/tmux-assistant-resurrect/test/run-tests.sh"]
49+
# TEST_BASH: override bash used by scripts under test (save/restore).
50+
# "bash" (default) = system bash 5; "bash3.2" = bash 3.2 awk-fallback path.
51+
# The test harness itself always runs under bash 5 (explicit in ENTRYPOINT).
52+
ENV TEST_BASH="bash"
53+
ENTRYPOINT ["/bin/bash", "/home/testuser/tmux-assistant-resurrect/test/run-tests.sh"]

test/run-tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set -euo pipefail
55

66
REPO_DIR="$HOME/tmux-assistant-resurrect"
77
JUNIT_FILE="${JUNIT_FILE:-/tmp/test-results/junit.xml}"
8+
echo "Test harness bash: $BASH_VERSION"
9+
echo "Scripts under test: $(${TEST_BASH:-bash} --version | head -1)"
10+
echo ""
811
PASS=0
912
FAIL=0
1013
ERRORS=""

0 commit comments

Comments
 (0)