Skip to content

test: add brainlayer run_tests.sh orchestrator#256

Merged
EtanHey merged 3 commits intomainfrom
feat/p4b-run-tests-orchestrator
Apr 27, 2026
Merged

test: add brainlayer run_tests.sh orchestrator#256
EtanHey merged 3 commits intomainfrom
feat/p4b-run-tests-orchestrator

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Apr 27, 2026

Summary

  • add scripts/run_tests.sh as a cross-language gate that runs the repo pytest legs plus any Bun .test.ts files under tests/
  • aggregate failures with bitwise OR and never short-circuit on the first failing command
  • add a pytest contract for exit aggregation and Bun-skip behavior when no TypeScript tests exist

Test plan

  • ruff check src/ tests/
  • uv run pytest tests/test_run_tests_script.py
  • bash -n scripts/run_tests.sh
  • ./scripts/run_tests.sh
    • local result: script correctly continued after a real pytest failure, then ran MCP registration pytest and the Bun Phase 2b fixture test
    • local pytest unit suite still failed on this machine due an environment dependency issue: ranx -> numba rejecting NumPy 2.4

Note

Medium Risk
Moderate risk because it introduces a new repo-wide test gate script and hardcodes a specific integration test target; CI behavior and failure reporting could change if environments lack bun/uv or tests move.

Overview
Adds scripts/run_tests.sh as a unified test entrypoint that runs the Python test suite (optionally via uv) plus any TypeScript .test.ts files via bun, while continuing through all phases and aggregating failures with a bitwise-OR exit code.

Adds contract tests (tests/test_run_tests_script.py) that stub pytest/bun to verify exit-code aggregation and that the bun phase is skipped when no TypeScript tests exist.

Reviewed by Cursor Bugbot for commit 954b3bc. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add run_tests.sh orchestrator script with pytest and bun test support

  • Adds scripts/run_tests.sh, a bash orchestrator that runs pytest unit tests, a specific MCP tool registration integration test, and bun TypeScript tests, aggregating all exit codes via bitwise OR into a single final status.
  • Bun tests are discovered dynamically under TEST_ROOT; if no .test.ts files exist, the bun step is skipped rather than failed.
  • Pytest can be invoked via uv run when BRAINLAYER_USE_UV=1 and uv is available, otherwise falls back to direct invocation.
  • Adds tests/test_run_tests_script.py with two integration tests that stub pytest and bun to verify exit code aggregation and bun-skip behavior.

Macroscope summarized 954b3bc.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Warning

Rate limit exceeded

@EtanHey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 39 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c624cba7-82be-44a8-91b2-7157ccbcc6a5

📥 Commits

Reviewing files that changed from the base of the PR and between 273d03e and 954b3bc.

📒 Files selected for processing (3)
  • BUGBOT_REVIEW.md
  • scripts/run_tests.sh
  • tests/test_run_tests_script.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/p4b-run-tests-orchestrator

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Apr 27, 2026

@codex review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Apr 27, 2026

@greptileai review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Apr 27, 2026

@cursor @BugBot review

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Apr 27, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 27, 2026

Perfect! Now let me create a summary of my review work:

Bugbot Review Summary

I completed a thorough code review of PR #256 (feat/p4b-run-tests-orchestrator) and identified 1 critical bug plus several lower-priority issues.

🔧 Critical Fix Applied

Bug Found: The pytest command included the -x flag (exit on first failure), which directly contradicted the PR's stated goal to "aggregate failures with bitwise OR and never short-circuit on the first failing command."

Impact: If any test in the unit suite failed, pytest would stop immediately, preventing the MCP tool registration tests and Bun test suite from running.

Fix Applied: Removed the -x flag from line 46 of scripts/run_tests.sh. Now all test phases run regardless of individual failures, with exit codes properly aggregated via bitwise OR.

Commit: 1d355cd

✅ Validation Results

  • Bash syntax check: PASS
  • Python linting (ruff): PASS
  • Contract tests: 2/2 PASSED
  • Exit code aggregation: Working correctly

⚠️ Remaining Non-Blocking Issues

Medium Priority:

  1. Hardcoded test_think_recall_integration.py::TestMCPToolCount reference lacks validation
  2. TypeScript test requires uv/uvx but has no dependency check or fallback

Low Priority:
3. Process substitution could use mapfile -t for better clarity
4. ROOT_DIR resolution lacks explicit error handling

These issues are documented in BUGBOT_REVIEW.md for future consideration but don't block merging.

📋 Final Status

Ready to merge - The critical bug has been fixed and all tests pass. The orchestrator script now correctly implements the "never short-circuit" behavior as designed.

Open in Web Open in Cursor 

…tion

Bugbot review found that the -x flag (exit on first failure) contradicts
the script's design goal to 'never short-circuit on the first failing command'.

This change ensures all test phases (unit suite, MCP tool registration, bun tests)
run regardless of individual failures, with exit codes properly aggregated via bitwise OR.

Co-authored-by: Etan Heyman <EtanHey@users.noreply.github.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca1989390e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/run_tests.sh
Comment on lines +37 to +38
if [ "$BRAINLAYER_USE_UV" = "1" ] && command -v uv >/dev/null 2>&1; then
uv run pytest "$@"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid forcing uv-managed pytest by default

When uv is installed, this branch always executes uv run pytest, which switches test execution to uv’s project environment and dependency sync path instead of the caller’s active Python environment. uv run --help documents a default PyPI index and that --active is needed to prefer the active venv, so in offline/pre-provisioned setups this can fail before running any tests (I reproduced this behavior: uv created .venv then failed fetching dependencies). Because BRAINLAYER_USE_UV defaults to 1, the script is brittle by default on machines that happen to have uv installed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 954b3bcadd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/run_tests.sh
run_step "pytest unit suite" run_pytest "$TEST_ROOT/" -v --tb=short -m "not integration"
run_step \
"pytest MCP tool registration" \
run_pytest "$TEST_ROOT/test_think_recall_integration.py::TestMCPToolCount" -v --tb=short
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Don't bind MCP check to overridable test root

The MCP leg is built from BRAINLAYER_TEST_ROOT, so any scoped run (e.g., pointing BRAINLAYER_TEST_ROOT at a temp/subset test directory) fails with pytest collection error file or directory not found for test_think_recall_integration.py::TestMCPToolCount even when all tests in that root pass. This makes the advertised test-root override unusable for partial runs and causes false failures in local/CI orchestration unless the override directory also mirrors this specific file.

Useful? React with 👍 / 👎.

@EtanHey EtanHey merged commit f2b3154 into main Apr 27, 2026
7 checks passed
@EtanHey EtanHey deleted the feat/p4b-run-tests-orchestrator branch April 27, 2026 17:43
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.

2 participants