Skip to content

Set mock search paths from the preprocessor's #includes (#1083 Case 1) - #1343

Merged
mkarlesky merged 2 commits into
next_versionfrom
fix/conditional-mock-includes
Oct 16, 2026
Merged

mkarlesky merged 2 commits into
next_versionfrom
fix/conditional-mock-includes

Conversation

@mkarlesky

Copy link
Copy Markdown
Member

Summary

This fixes a 1.2.0 prerelease regression, #1083 Case 1, and a second regression with the same cause.

A test's mock search paths came from stage 2's text scan of its #includes. That scan ignores #if, and the paths were never revisited after stage 4 settled the list through the preprocessor (introduced in 41602f17, first in v1.2.0-pre.8). Two things went wrong:

  • A mock in an #if branch that is off, whose header does not exist, stopped the build in every mode (Found no file `Gpt_HwType1.h` ). On 1.1.10 it builds with :tests and :all.
  • A mock only the preprocessor sees got no search path, such as one a macro names with its header in a subdirectory. Its generated mock was never found (mock_widget.h: No such file or directory). On 1.1.10 it builds.

Changes

  • FileFinder#resolve_mock / #find_header_input_for_mock take complain:, defaulting to :error. With a tolerating level, a missing header resolves to [nil, nil]. Existing callers are unchanged.
  • Stage 2 (collect_mock_search_paths) skips a scanned mock without a header when test preprocessing is on, because the preprocessor may discard it. With preprocessing off, the scanned list is the build's own, and a missing header still stops the build.
  • Stage 4, first pass, where reconciliation follows, sets the mock search paths again from GCC's -MM -MG list, which is the only source reconciliation draws on. This happens before the directives-only pass, which needs those paths to find the stand-ins.
  • Stand-in headers are now placed when the bare-includes list is recalled from cache, too, not only when it is extracted.
  • lib/ceedling/test_invoker/PIPELINE.md is revised against the code: the two #include lists, stage 4's three passes, stand-ins, where mock search paths come from, and corrections throughout.

No Changelog entry, since this is a prerelease regression.

Testing

  • Unit specs cover:
    • stage 2's tolerance and strictness;
    • pass 1 setting the paths from fresh and cached lists;
    • mocks the preprocessor discards never being resolved;
    • pass 2 receiving the rebuilt paths;
    • fallback mode leaving stage 2's paths in place;
    • stand-ins on a cache hit.
  • New system spec, conditional_mock_includes:
    • Case 1 as reported passes with :tests and :all;
    • with :none, and with fallback preprocessing forced, the build stops naming the missing header, which pins the known gap;
    • the macro-named mock in a subdirectory passes with :tests and :all.
  • Results:
    • rake specs:units and rake specs:integration pass, and lint is clean;
    • the new spec passes on the macOS host (Apple Clang) and in madsciencelab-plugins (GCC 14);
    • the related system specs pass in Docker.

#1083 stays open for Case 2, which needs its own design.

🤖 Generated with Claude Code

mkarlesky and others added 2 commits October 16, 2026 09:51
A test's mock search paths came from the text scan of its #includes, which
ignores #if, and were never revisited once preprocessing settled the list.
A mock in a branch that is off, whose header does not exist, stopped the
build (#1083), and a mock only the preprocessor sees, such as one a macro
names, got no search path for its mirrored directory.

The text-scan paths now skip a mock without a header when test
preprocessing is on. Where stage 4 reconciles, its first pass sets the
paths again from the preprocessor's list, and it places stand-ins for a
list recalled from cache too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mkarlesky
mkarlesky merged commit 847e5d3 into next_version Oct 16, 2026
22 checks passed
@mkarlesky
mkarlesky deleted the fix/conditional-mock-includes branch October 16, 2026 18:04
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.

1 participant