Skip to content

Support mixins referencing other mixins via a reserved 'mixin' key - #69

Open
PiousCrossten wants to merge 6 commits into
colcon:masterfrom
PiousCrossten:feature/mixins-referencing-mixins
Open

Support mixins referencing other mixins via a reserved 'mixin' key#69
PiousCrossten wants to merge 6 commits into
colcon:masterfrom
PiousCrossten:feature/mixins-referencing-mixins

Conversation

@PiousCrossten

@PiousCrossten PiousCrossten commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Lets a mixin reference other mixins through a reserved mixin key holding a list of mixin names, so a bigger mixin can be built out of smaller ones. Addresses #39.

About the diff: this branch sits on top of #59, which is approved but not merged yet, so the four commits from that PR show up here as well. The composition work is the last two commits. Happy to rebase once #59 goes in.

  • The new module colcon_mixin/mixin/order.py works out the application order with a depth first post-order walk. A mixin reachable through more than one path is applied once per path so that last one wins still holds, cycle detection only looks at the active recursion path, and circular, unknown or malformed references each raise their own error.

  • In mixin_argument.py the references are applied before the mixin itself, so a mixin can override what it inherits. The reserved mixin key is skipped during the overlay since it is metadata and not an argument. Mixins that don't use the key behave exactly as before.

  • test/test_order.py covers the ordering algorithm and the error cases, test/test_mixin_argument.py covers nested references, scalar overrides and command line precedence.

Claude Opus (via Antigravity) was used for generating test cases and for architecture level testing. The design, implementation and final review are my own.

PiousCrossten and others added 4 commits June 24, 2026 00:56
When multiple mixins provided list arguments (e.g. cmake-args) they were
concatenated in reverse of the order given on the command line: each
mixin prepends its values, and applying the mixins in forward order
stacked them backwards. Apply the mixins in reverse so the resulting
list follows the order the mixins were given while keeping any explicit
command line arguments last. As a side effect this also lets a later
mixin override a scalar value set by an earlier one.

The requested mixins are still validated in the given order so an error
reports the first unavailable mixin.

Add regression tests covering list ordering, scalar override and command
line precedence.
Co-authored-by: Kimberly N. McGuire <kimberleymcguire@gmail.com>
Remove comment about command line arguments order.
@codecov-commenter

codecov-commenter commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.03%. Comparing base (ebedd27) to head (5c19fa3).

Additional details and impacted files
@@             Coverage Diff             @@
##           master      #69       +/-   ##
===========================================
+ Coverage   15.30%   39.03%   +23.73%     
===========================================
  Files          11       12        +1     
  Lines         562      602       +40     
  Branches       94      102        +8     
===========================================
+ Hits           86      235      +149     
+ Misses        474      353      -121     
- Partials        2       14       +12     

☔ 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.

Add colcon_mixin/mixin/order.py, a standalone module that computes the
application order for a mixin together with the other mixins it
references through a 'mixin' key. It uses a depth-first, post-order
traversal with re-application: referenced mixins are recorded before the
mixin that references them, and a mixin reachable through multiple paths
is applied once per path to preserve last-applied-wins semantics. Cycle
detection uses the active recursion path only, so legitimate
re-application is never mistaken for a cycle. Circular references,
unknown references and malformed 'mixin' keys raise dedicated errors.

Add unit tests covering the ordering algorithm, the canonical reference
graph and error reporting.

Assisted-by: Claude Opus (Antigravity) for test case generation and
  architecture-level testing
Expand each requested mixin into its full application order using
colcon_mixin.mixin.order and apply the result in reverse, so the
prepend-based overlay produces the computed order while explicit command
line arguments keep precedence. A referencing mixin is applied
conceptually last and can override values inherited from its references.
Skip the reserved 'mixin' key during overlay since it is metadata, not
an argument. Report circular, unknown and malformed references as clean
CLI errors. Mixins without a 'mixin' key behave exactly as before.

Add parser integration tests covering nested references, scalar
overrides, command line precedence and error reporting.

Assisted-by: Claude Opus (Antigravity) for test case generation and
  architecture-level testing
@PiousCrossten
PiousCrossten force-pushed the feature/mixins-referencing-mixins branch 2 times, most recently from 5c19fa3 to df953e1 Compare August 4, 2026 05:39
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