Skip to content

test: fail fast under --no-build when a needed binary is missing; add --no-chemistry - #1934

Merged
sbryngelson merged 2 commits into
MFlowCode:masterfrom
sbryngelson:test-nobuild-preflight
Oct 5, 2026
Merged

sbryngelson merged 2 commits into
MFlowCode:masterfrom
sbryngelson:test-nobuild-preflight

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Problem

./mfc.sh build followed by ./mfc.sh test --no-build runs the full suite and fails every chemistry case at the end. Under --no-build, build() does nothing, and ./mfc.sh build never produces the chemistry build variant (one *-chem-<hash> slug per mechanism). The same applies to any case whose slug differs from the plain build (e.g. analytic initial conditions in pre_process), or when build and test flags disagree.

Change

  • --no-build preflight: before running anything, check that every (target, slug) the selected cases need has an installed binary. If not, list each missing build with an example case and the expected path, then exit non-zero. Behavior without --no-build is unchanged.
  • --no-chemistry: skip cases with chemistry = 'T'. Filters on the parameter rather than the trace, so reacting Example cases are covered too. Suggested by the preflight error when every missing build is a chemistry one.
  • Documented in testing.md; unit tests in toolchain/mfc/test/test_nobuild_preflight.py.
$ ./mfc.sh build && ./mfc.sh test --no-build --only 1D
Error: --no-build was given, but 2 build(s) needed by 10 test case(s) are missing:
  pre_process [cpu-chem-<hash>]: 10 case(s), e.g. 1D -> Chemistry -> Perfect Reactor (5DCF300C) (+9 more)
    expected build/install/cpu-chem-<hash>/bin/pre_process
  simulation [cpu-chem-<hash>]: 10 case(s), e.g. 1D -> Chemistry -> Perfect Reactor (5DCF300C) (+9 more)
    expected build/install/cpu-chem-<hash>/bin/simulation
Build them by rerunning this command with --dry-run in place of --no-build, or drop --no-build to build and test in one go.
Note that ./mfc.sh build alone does not build case-specific variants such as chemistry.
All of the affected cases use chemistry; pass --no-chemistry to skip them.

Testing

  • ./mfc.sh build, then test --no-build --only 1D: fails immediately with the error above.
  • test --no-build --only 1D --no-chemistry: 175 passed, 0 failed.
  • ./mfc.sh precheck passes.

CI already builds every slug with test --dry-run before test --no-build, so the preflight passes there.


Acknowledgement

  • I confirm this PR meets the above expectations and reflects my own understanding and real-world context.

… --no-chemistry

Under --no-build, build() is a no-op, so a case whose build variant was never
compiled failed only when it ran. Chemistry is the usual one: ./mfc.sh build
does not produce the chemistry variant, so a full suite ran for its whole length
before the chemistry cases failed at the end.

Before running any case, check that every (target, slug) the selected cases need
has an installed binary. If any are missing, list each with an example case and
the expected path, and exit non-zero. When every affected case uses chemistry,
suggest --no-chemistry.

--no-chemistry skips cases with chemistry = 'T'. It keys on the parameter, not
the trace, because Example cases built on reacting examples need a chemistry
build but carry no "Chemistry" trace element.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 02:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds a --no-build preflight check to fail fast when required binaries are missing, and introduces --no-chemistry to skip chemistry-enabled test cases (useful when chemistry build variants aren’t installed).

Changes:

  • Add --no-build preflight to detect missing (target, slug) binaries before running any tests and emit a consolidated error message.
  • Add --no-chemistry CLI flag and filtering logic to skip cases with chemistry = T.
  • Add docs and unit tests covering preflight grouping/counting and chemistry filtering behavior.
File Description
toolchain/​mfc/​test/​test_nobuild_preflight.py New unit tests for missing-binary preflight and chemistry skipping.
toolchain/​mfc/​test/​test.py Implements chemistry detection/filtering, missing-binary discovery, and the --no-build preflight in test().
toolchain/​mfc/​cli/​commands.py Adds the new --no-chemistry flag.
docs/​documentation/​testing.md Documents --no-chemistry and the new --no-build preflight behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread toolchain/mfc/test/test.py Outdated
continue
checked.add(key)
binpath = code.get_install_binpath(input_file)
if not os.path.isfile(binpath):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c0de563: the preflight now requires os.path.isfile(binpath) and os.access(binpath, os.X_OK), with a test that a non-executable file is reported as missing.

Comment thread toolchain/mfc/test/test.py Outdated
@@ -368,6 +416,8 @@ def test():

cases, skipped_cases = __filter(cases)
cases = [_.to_case() for _ in cases]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c0de563. The filter can't move before to_case(): Example cases only know their chemistry value after their case.py is loaded. So _drop_chemistry_cases now takes the builders alongside the converted cases and appends the skipped builders. skipped_cases stays a list of builders, as __filter returns it.

Comment on lines +361 to +366
lines = [f"--no-build was given, but {len(unbuilt)} build(s) needed by {n_cases} test case(s) are missing:"]
for entry in unbuilt:
cases = entry["cases"]
more = f" (+{len(cases) - 1} more)" if len(cases) > 1 else ""
lines.append(f" {entry['target']} [{entry['slug']}]: {len(cases)} case(s), e.g. {cases[0].trace} ({cases[0].get_uuid()}){more}")
lines.append(f" expected {entry['binpath']}")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leaving this as is: the output is already deterministic, because it follows list_cases() order, which is fixed. Listing missing builds in suite order also matches the order the cases would have run.

Address review: the --no-build preflight now also requires the binary to be
executable, and --no-chemistry appends the skipped cases' builders rather than
their converted TestCases, so skipped_cases holds one type as __filter leaves it.
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.82%. Comparing base (ed7a238) to head (c0de563).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1934   +/-   ##
=======================================
  Coverage   62.82%   62.82%           
=======================================
  Files          86       86           
  Lines       22394    22394           
  Branches     3305     3305           
=======================================
  Hits        14070    14070           
  Misses       6071     6071           
  Partials     2253     2253           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson
sbryngelson merged commit 3e74faa into MFlowCode:master Oct 5, 2026
413 of 434 checks passed
@sbryngelson
sbryngelson deleted the test-nobuild-preflight branch October 5, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants