Skip to content

[bug] bats-core self-suite: bats.bats/bats_pipe.bats hang after 'Executed 0 of expected N tests' (301 tests unharvestable); 3 more setup failures misattribute failing lines to bats-exec-test:4/6 — 13/20 files fully green at this base #364

Closed

Description

@caomengxuan666

Found by ecosweep4 lane (wt22/nest22; corpus: bats-core own test/ suite — re-run of the ecosuite §4 blocked suite now that #172/#224 are closed; worktree base a522eb3, release build; oracle WSL GNU Bash 5.3.0 script-file runs; 20 test files, timeout 150 s each).

Headline: the ecosuite blockers are dead

With #172 (exec env) and #224 ($0/BASH_SOURCE path domain) closed, bin/bats runs unpatched under rubash (no harvest patch needed this time): bats --version OK, and 13 of 20 test files pass fully green with byte-identical TAP vs GNU (GNU itself: 20/20 files, 403/403 tests green on the same tree):

fully green: cat-formatter 5, common 9, file_setup_teardown 17, filter 6, install 5, junit-formatter 13, run 18, suite_setup_teardown 19, tagging 10, tap13 4, timeout 4, trace 2, warnings 8.

The reds

1. bats.bats (146 tests) and bats_pipe.bats (155 tests) — TIMEOUT, "Executed 0 of expected N"

Both print 1..146 / 1..155 then # bats warning: Executed 0 instead of expected 146 tests and hang to the 150 s timeout (rc=124). The gather phase works; zero test bodies execute. Repro: timeout 60 rubash bin/bats -f simple test/bats.bats → stderr shows bats-preprocess being executed with broken semantics:

libexec/bats-core/bats-preprocess: line 1: : No such file or directory
libexec/bats-core/bats-preprocess: line 1: normalize_variable_list: command not found
ERROR: Found no tests.

bats-preprocess is invoked by bats_preprocess_source() as CHECK_BATS_COMMENT_COMMANDS=1 "$BATS_ROOT/libexec/bats-core/bats-preprocess" "$BATS_TEST_FILENAME" >"$BATS_TEST_SOURCE" (lib/bats-core/preprocessing.bash) — env-prefix + external script + stdout redirect. The "line 1" errors plus "command not found" for a function defined in the same file indicate the script is being executed with broken line tracking / not as a coherent script — suspected interaction with the in-process script-execution model of rubash#363 (this lane) and/or the env-prefix+redirect combination.

2. setup-time failures misattributing the failing line — load.bats (2), formatter.bats (1)

  • load.bats load supports plain symbols / load doesn't support _declare_d symbols: setup's load test_helper.bash fails, reporting `BATS_EXTENDED_SYNTAX='' failed — that is line 6 of bats-exec-test (plain startup assignment), not anything in the loaded file.
  • formatter.bats default formatter in interactive shell is interactive pretty: setup fails reporting `# Variables used in other scripts.' failed — that is the line-4 comment of bats-exec-test.

A comment/plain-assignment "failing" during an unrelated load points at bats' ERR-trap/stack-trace machinery (bats runs set -e + ERR/DEBUG/RETURN traps and renders custom stack traces) misfiring under rubash — cf. trap family rubash#343/#344/#345. Not isolated further this lane.

3. Env-bound (not counted)

  • parallel.bats 35 "not ok … # skip --jobs requires GNU parallel" — bats' own platform skip (no GNU parallel on Windows); GNU runs them.
  • root.bats 9 — "# skip symbolic links aren't functional on OSTYPE=msys".
  • suite.bats recursive support with symlinks — same symlink class.

Artifacts

Value

bats.bats + bats_pipe.bats are the two densest execution-plane files of the most-used bash test framework (301 tests: run/redirect/pipe/exit-code/timeout semantics). Unblocking them is the natural next harvest after this issue + #362/#363.

Activity

  1. added
    bug
    on Sep 30, 2026
  2. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Not downstream of #358/#363 (both fixed; post-fix binary still rc=124 identically to master). Isolated repro: in-process bats-preprocess output is CORRECT (wrap rc=0, preprocessed artifact good) but stderr shows phantom 'line 1: : No such file or directory' x2 plus normalize_variable_list: command not found (that function is defined INSIDE the preprocessed test/bats.bats = its content is being executed); via env (real subprocess) everything is clean; small .bats files and $(<file) are clean — the trigger is specific content in test/bats.bats hitting the execution plane. Needs a dedicated deep-dive lane; kept open.

  3. caomengxuan666 commented on Oct 1, 2026

    @caomengxuan666
    MemberAuthor

    Root cause found and fixed (wt23/bats364 lane; fix + regression suite on the lane branch, byte-verified against WSL GNU Bash 5.3.0).

    Root cause (the bats-preprocess corruption)

    expand_assignment_value_inner (src/executor/assignment_expansion.rs) ran a post-expansion scan that materialized <(/>( spans found ANYWHERE in the EXPANDED assignment value. Text arriving from a parameter-expansion RESULT is data in GNU — expand_word_internal cases '<'/'>' (subst.c:11358-11381) recognize a process substitution only while the word walker scans the ORIGINAL word text; expansion results are appended via add_string/sub_append_string (subst.c:11352-11356) and never rescanned.

    So bats-preprocess's per-line line="${line//$'\r'/}" executed the <(normalize_variable_list ...) text living in test/bats.bats lines 1382-1383 and rewrote the preprocessed source with /dev/fd/N — the phantom stderr, the corrupted gather, and the hang. Fix: gate the fallback materialization on the PRE-expansion RHS carrying a literal <(/>( (and not being wholly double-quoted). var=<(cmd) literal form still substitutes through the raw-RHS path (8f8caca).

    Verification:

    • bats-preprocess on test/bats.bats: output now BYTE-IDENTICAL to GNU, zero stderr (was: 4 phantom lines + 2 rewritten lines).
    • bats_pipe.bats: 155/155 ok, TAP byte-identical to GNU (was: 150s timeout, 0 tests).
    • bats.bats: tests now execute and pass — 70/146 all-ok in a 300s window (was 0). New suite tests/issue364_assignment_procsub_rescan_regressions.rs (8 cases, GNU-probed matrix A-E + the CR-strip loop shape).

    What still blocks the full 146-test harvest: performance, not semantics

    bats.bats needs ~10 min under rubash (GNU: <1 s). Profile: per DEBUG-trap firing ~0.4-1 ms (release) × ~2300 firings per gather (bats_debug_trap copies BASH_LINENO/BASH_SOURCE arrays and runs a $(cd path; pwd) normalization that GNU on Linux never pays); plus general per-command overhead. Suggest a dedicated perf lane (trap-action caching, cheaper special-array reads, cheaper comsub) — not a semantic bug.

    Environment noise (not rubash)

    bats names its runlogs 2026-10-01 05:21:10 UTC.log; NTFS rejects the colons → one bats-exec-test: line 190: Invalid argument per test on the rubash side (GNU under DrvFs escapes them). Windows filename rule; do not count in the ledger.

  4. added a commit that references this issue on Oct 1, 2026
  5. caomengxuan666 commented on Oct 1, 2026

    @caomengxuan666
    MemberAuthor

    Landed on master as 2ad6c17 (cherry-picked from wt23/bats364 lane commit 42f0d60d): fix + tests/issue364_assignment_procsub_rescan_regressions.rs (8 cases) + triage table docs/ecosweep4-B-reds-triage-2026-10-01.md. All five gates green locally; remote CI green on 2ad6c17 (all 6 jobs).

    Outcome recap: bats-preprocess byte-identical to GNU with zero stderr; bats_pipe.bats 155/155 TAP byte-identical; bats.bats 70/146 all-ok (was 0/hang). The remaining wall-clock gap is tracked in #375 (perf lane) — not a semantic bug. NTFS runlog-colon noise documented above, not counted.

    Triage siblings from the same lane: #369 #370 (true regressions, bisected), #371 #372 (semantic gaps), #373 #374 (test-maintenance follow-ups).

  6. added a commit that references this issue on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions