Skip to content

refactor: share test and demo command setup - #2322

Merged
codeforester merged 1 commit into
mainfrom
enhancement/2297-20260918-deduplicate-test-and-demo-argument-parsing-and-resolved-comm
Sep 19, 2026
Merged

codeforester merged 1 commit into
mainfrom
enhancement/2297-20260918-deduplicate-test-and-demo-argument-parsing-and-resolved-comm

Conversation

@codeforester

@codeforester codeforester commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Move the common test/demo option parser and project resolution context into project_command_helpers.sh.
  • Keep command-specific preflight, trust, runner, and direct demo-script behavior in their respective commands.
  • Add boundary coverage for duplicate project options and path/argument values containing spaces, newlines, and tabs.

Validation

  • 50 focused BATS tests across test, demo, project-command helpers, and manifest-command trust.
  • ShellCheck on touched shell/BATS files.
  • git diff --check.

AI-context docs are unchanged because this is an internal refactor with no new user-facing contract.

Fixes #2297

@codeforester
codeforester requested a review from a team as a code owner September 18, 2026 17:02
@codeforester
codeforester merged commit 7485486 into main Sep 19, 2026
22 checks passed
@codeforester
codeforester deleted the enhancement/2297-20260918-deduplicate-test-and-demo-argument-parsing-and-resolved-comm branch September 19, 2026 11:45

@codeforester codeforester left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review findings (note: reviewed after merge — flagging for a follow-up if these matter)

  1. Confirmed regression - history context no longer set on failed resolve (cli/bash/commands/basectl/subcommands/project_command_helpers.sh, base_project_command_resolve_context): in the pre-refactor code (both demo.sh and test.sh on main at 2ab3e09c), base_project_set_history_context ran before the four-field validation check that can trigger base_std_fatal_error. In the new shared base_project_command_resolve_context, the order is reversed: the validation check now runs first, and base_project_set_history_context is only reached if it passes. I verified this directly against both versions of the source. Concretely: running basectl demo myproject (or basectl test myproject) against a project that resolves fine (name/root/manifest all populate) but has no demo script/test command configured used to still export BASE_CLI_HISTORY_PROJECT/_PROJECT_ROOT/_MANIFEST before exiting with the fatal error; now it exits without ever setting them. Anything relying on that history context being populated even on this specific failure path (e.g. shell history/audit tooling) will silently stop seeing it.

  2. Wrapper executable check gap (test.sh, the --test-preflight resolve call): the -x check on $BASE_HOME/bin/base-wrapper now only guards the first wrapper invocation (inside base_project_command_resolve_context); the second, hand-rolled preflight call re-derives wrapper with no accompanying check. Low severity in practice — a separate trust check earlier in the same call path happens to catch a missing/non-executable wrapper first — but it's a real gap if that mitigation ever moves.

  3. Wrapper path still hardcoded in 3 places: $BASE_HOME/bin/base-wrapper is independently declared in base_project_require_manifest_command_trust, the new base_project_command_resolve_context, and inline in test.sh's preflight call — despite this PR's purpose being to deduplicate exactly this kind of shared logic.

Posted via Claude Code

codeforester added a commit that referenced this pull request Sep 19, 2026
…2328)

## Summary

- restore resolved history context before validating the required
test/demo action
- add regression coverage for missing test commands and demo scripts

## Issue

Fixes #2324

Follow-up to the merged PR #2322 review finding `5256545518`.

## Validation

- `bats cli/bash/commands/basectl/tests/project-command-helpers.bats
cli/bash/commands/basectl/tests/test.bats
cli/bash/commands/basectl/tests/demo.bats` (45 passed)
- `git diff --check`
- ShellCheck on changed files

## Notes

The fatal error and nonzero behavior remain unchanged; only the ordering
of context capture is restored.
codeforester added a commit that referenced this pull request Sep 19, 2026
## Summary

- centralize the project-command wrapper path and executable guard
- validate the wrapper immediately before the test preflight invocation
- add focused coverage for a missing or non-executable wrapper

## Issue

Fixes #2325

Follow-up to the merged PR #2322 review findings `5256545518`.

## Validation

- `bats cli/bash/commands/basectl/tests/project-command-helpers.bats
cli/bash/commands/basectl/tests/test.bats
cli/bash/commands/basectl/tests/manifest-command-trust.bats` (37 passed)
- `git diff --check`
- ShellCheck on changed files

## Notes

The change is limited to the shared project-command path; unrelated Base
wrapper call sites and manifest trust policy are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplicate test and demo argument parsing and resolved-command setup

1 participant