Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Fixed
- `watch` subcommand failed with `bashunit::watch::run: command not found` in the released binary because `src/watch.sh` was missing from the build; it is now bundled (#735)

### Changed
- Faster test execution by removing subprocess forks from hot paths (no behaviour change)

Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function build::dependencies() {
"src/helpers.sh"
"src/test_title.sh"
"src/upgrade.sh"
"src/watch.sh"
"src/assertions.sh"
"src/reports.sh"
"src/runner.sh"
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/build_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

ROOT_DIR=""

function set_up_before_script() {
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
}

function src_files_sourced_by_entrypoint() {
# Dev-only helpers under src/dev/ are intentionally excluded from the build.
grep -oE 'src/[a-zA-Z0-9_/]+\.sh' "$ROOT_DIR/bashunit" | grep -v '^src/dev/' | sort -u
}

function src_files_in_build() {
grep -oE 'src/[a-zA-Z0-9_/]+\.sh' "$ROOT_DIR/build.sh" | sort -u
}

# Every src file the dev entrypoint sources (except dev-only helpers) must also be
# bundled by build.sh, otherwise its functions are missing from the distributable
# single-file binary (regressions: bench #0.31.0, watch #735).
function test_build_bundles_every_src_file_sourced_by_entrypoint() {
local missing
missing=$(comm -23 <(src_files_sourced_by_entrypoint) <(src_files_in_build))

assert_empty "$missing"
}

function test_built_binary_defines_watch_run() {
local build_dir
build_dir=$(bashunit::temp_dir)

(cd "$ROOT_DIR" && bash build.sh "$build_dir") >/dev/null 2>&1

assert_file_exists "$build_dir/bashunit"
assert_equals "1" "$(grep -c 'function bashunit::watch::run()' "$build_dir/bashunit")"
}
Loading