Skip to content

Add subtractive notation to TEST_SOURCE_FILE() - #1214

Merged
mkarlesky merged 1 commit into
next_versionfrom
test-source-file-subtractive
Aug 19, 2026
Merged

Add subtractive notation to TEST_SOURCE_FILE()#1214
mkarlesky merged 1 commit into
next_versionfrom
test-source-file-subtractive

Conversation

@mkarlesky

Copy link
Copy Markdown
Member

Summary

TEST_SOURCE_FILE() only ever added a file to a test executable's build. A test file that both #includes a header and separately names a same-basename source could already override the implicit header/source convention, but there was no way to remove a file that convention pulls in for any other reason — for instance, a same-named file elsewhere in the project whose symbols conflict with what a test actually needs.

  • A -: prefix on an entry now removes the named file from a test's final compile/link list outright, using the same +:/-: notation already available for :paths list entries.
  • Unlike the existing override (which only cancels one same-basename header match), removal applies to the fully assembled list regardless of how a file got there — the implicit convention, a positive TEST_SOURCE_FILE() entry, or a Partial — and is logged the same way the override already is.
  • Collection, validation, and additive/subtractive resolution for this directive were previously split between TestBuildExecutor and TestBuildPlanner. They're now owned by one dedicated class, TestSourceFileDirectiveResolver, with its own focused test coverage.
  • The two previously separate system spec files covering path disambiguation and the override behavior are consolidated, along with new additive/subtractive coverage, into a single spec/system/test_source_file_directive_spec.rb.

Test plan

  • Unit: spec/units/test_source_file_directive_resolver_spec.rb covers #resolve, #validate!, and #remove_subtracted directly.
  • Unit: spec/units/test_build_executor_spec.rb and spec/units/test_build_planner_spec.rb updated for the delegation, plus new subtractive-specific scenarios in #extract_sources.
  • Full local unit suite green (2556 examples, 0 failures).
  • System: spec/system/test_source_file_directive_spec.rb (5 scenarios) and the trimmed spec/system/implicit_source_header_correspondence_disambiguation_spec.rb (2 scenarios) both green via Docker (madsciencelab-plugins:v1.1.4).
  • Docs updated: testing-guide/build-directives.md, testing-guide/conventions.md, configuration/reference/paths.md.

TEST_SOURCE_FILE() only ever added a file to a test executable's
build. A test file that both #includes a header and separately names
a same-basename source could already override the implicit
header/source convention, but there was no way to remove a file that
convention pulls in for any other reason -- for instance, a same-named
file elsewhere in the project whose symbols conflict with what a test
actually needs.

A "-:" prefix on an entry now removes the named file from a test's
final compile/link list outright, using the same +:/-: notation
already available for :paths list entries. Unlike the existing
override, removal applies to the fully assembled list regardless of
how a file got there -- the implicit convention, a positive
TEST_SOURCE_FILE() entry, or a Partial -- and is logged the same way
the override already is.

Collection, validation, and additive/subtractive resolution for this
directive were previously split between TestBuildExecutor and
TestBuildPlanner. They're now owned by one dedicated class,
TestSourceFileDirectiveResolver, with its own focused test coverage.
@mkarlesky
mkarlesky merged commit 23b38ad into next_version Aug 19, 2026
35 of 40 checks passed
@mkarlesky
mkarlesky deleted the test-source-file-subtractive branch August 19, 2026 23:28
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.

Expand TEST_SOURCE_FILE() to allow module subtraction from a test executable build

1 participant