From 4009ce89aad3a10127112a0b8bf13e896b1c64db Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Sat, 1 Aug 2026 13:28:06 +0200 Subject: [PATCH] refactor(console): group the rendering files into a src/console/ module Group 2 under #940. Three files and 1220 lines that already shared a prefix and a concern: src/colors.sh -> src/console/colors.sh src/console_header.sh -> src/console/header.sh src/console_results.sh -> src/console/results.sh colors.sh defines the _BASHUNIT_COLOR_* palette the other two render with; both of those depend on the same env/helper/parallel set. The index sources them in the order the entrypoint used, so nothing about load order changes. The console_ prefix drops inside the directory, which now carries the concept. No function is renamed and no line of any moved file changes: git records all three as renames with a zero-line diff. .editorconfig pinned `indent_size = unset` for src/console_header.sh and is repointed at src/console/header.sh. Missing that would have silently applied the global rule to a file deliberately exempt from it -- the trap ADR-010 records from #928. Grouped before splitting on purpose: console_results.sh is also listed on #931 at 828 lines. Moving it into the module first means the eventual split happens inside src/console/ instead of the two issues colliding on the same file. The built artifact's code content is identical -- every difference is a comment or an embed marker -- and `bash build.sh bin -v` prints "Build verified". Related #940 --- .claude/rules/architecture-map.md | 4 +++- .editorconfig | 2 +- bashunit | 4 +--- src/{ => console}/colors.sh | 0 src/{console_header.sh => console/header.sh} | 0 src/console/index.sh | 13 +++++++++++++ src/{console_results.sh => console/results.sh} | 0 7 files changed, 18 insertions(+), 5 deletions(-) rename src/{ => console}/colors.sh (100%) rename src/{console_header.sh => console/header.sh} (100%) create mode 100644 src/console/index.sh rename src/{console_results.sh => console/results.sh} (100%) diff --git a/.claude/rules/architecture-map.md b/.claude/rules/architecture-map.md index 25d7f392..95a8da54 100644 --- a/.claude/rules/architecture-map.md +++ b/.claude/rules/architecture-map.md @@ -63,7 +63,9 @@ shell (or, in parallel, in per-test `.result` files aggregated at the end). | `state.sh` | counters, per-test payload encode/decode, TAP conversion | | `env.sh` | all `BASHUNIT_*` defaults/config files, scratch dirs (`_BASHUNIT_RUN_OUTPUT_DIR` + EXIT-trap cleanup) | | `parallel.sh` | worker temp tree, aggregation, stop-on-failure flag file | -| `console_header.sh` / `console_results.sh` | header/totals rendering, deferred failed/skipped/incomplete/risky blocks (scratch files under the run dir) | +| `console/index.sh` | aggregator only — sources the `src/console/` module below | +| `console/colors.sh` | the `_BASHUNIT_COLOR_*` palette and `bashunit::sgr` | +| `console/header.sh` / `console/results.sh` | header/totals rendering, deferred failed/skipped/incomplete/risky blocks (scratch files under the run dir) | | `assert/index.sh` | aggregator only — sources the `src/assert/` module below, plus `skip_todo.sh` and `test_doubles.sh` | | `assert/core.sh` | `assert::should_skip`, `assert::fail_with`, `assert::join_to_slot` and the comparison assertions the other files build on | | `assert/{arrays,assertions,dates,duration,files,folders,json,once,snapshot}.sh` | the per-topic assertions; the per-assertion path must stay fork-free | diff --git a/.editorconfig b/.editorconfig index 45fce408..0173d7b2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,7 +26,7 @@ indent_size = 2 [{Makefile,**.mk,.git*}] indent_style = tab -[{tests/acceptance/**.sh,src/console_header.sh,docs/command-line.md}] +[{tests/acceptance/**.sh,src/console/header.sh,docs/command-line.md}] indent_size = unset [.claude/**.md] diff --git a/bashunit b/bashunit index ae6cf529..1db3b96e 100755 --- a/bashunit +++ b/bashunit @@ -76,9 +76,7 @@ source "$BASHUNIT_ROOT_DIR/src/env.sh" source "$BASHUNIT_ROOT_DIR/src/coverage/index.sh" source "$BASHUNIT_ROOT_DIR/src/clock.sh" source "$BASHUNIT_ROOT_DIR/src/state.sh" -source "$BASHUNIT_ROOT_DIR/src/colors.sh" -source "$BASHUNIT_ROOT_DIR/src/console_header.sh" -source "$BASHUNIT_ROOT_DIR/src/console_results.sh" +source "$BASHUNIT_ROOT_DIR/src/console/index.sh" source "$BASHUNIT_ROOT_DIR/src/helpers.sh" source "$BASHUNIT_ROOT_DIR/src/test_title.sh" source "$BASHUNIT_ROOT_DIR/src/upgrade.sh" diff --git a/src/colors.sh b/src/console/colors.sh similarity index 100% rename from src/colors.sh rename to src/console/colors.sh diff --git a/src/console_header.sh b/src/console/header.sh similarity index 100% rename from src/console_header.sh rename to src/console/header.sh diff --git a/src/console/index.sh b/src/console/index.sh new file mode 100644 index 00000000..9b4fc5b1 --- /dev/null +++ b/src/console/index.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Entry point for the src/console/ module: only `source` lines and comments +# belong here. build.sh emits a file's body before recursing into its `source` +# lines, so any statement here would run before its dependencies in the built +# binary (adrs/adr-010-src-module-directories.md). +# +# colors.sh first: it defines the _BASHUNIT_COLOR_* palette that header.sh and +# results.sh render with. Order matches the entrypoint's before this module +# existed. +source "$BASHUNIT_ROOT_DIR/src/console/colors.sh" +source "$BASHUNIT_ROOT_DIR/src/console/header.sh" +source "$BASHUNIT_ROOT_DIR/src/console/results.sh" diff --git a/src/console_results.sh b/src/console/results.sh similarity index 100% rename from src/console_results.sh rename to src/console/results.sh