Skip to content

Conversation

@Alizter
Copy link
Collaborator

@Alizter Alizter commented Nov 5, 2025

We add a way to find if an ml source comes from a (tests) stanza. We also take the opportunity to improve the error message when there are overlapping tests / executables.

@Alizter Alizter requested a review from rgrinberg November 5, 2025 12:21
@Alizter Alizter force-pushed the push-sqsrlxzuzmwr branch 3 times, most recently from 1a422a3 to a6438da Compare November 5, 2025 12:29
@rgrinberg
Copy link
Member

rgrinberg commented Nov 5, 2025

Where do we use the information that a module comes from a test stanza?

EDIT: the change itself isn't bad, but it lacks motivation. It does not improve the code on its own, but it could be justified if it's a stepping stone for another feature or fix. I'd like to see where this is going first.

Comment on lines 497 to +526
`Executables { Per_stanza.stanza = exes; sources; modules; obj_dir; dir }
in
let make_tests ~dir ~expander ~modules ~project tests =
let+ result = make_executables ~dir ~expander ~modules ~project tests.Tests.exes in
match result with
| `Executables group_part -> `Tests { group_part with stanza = tests }
| _ -> assert false
Copy link
Member

@shonfeder shonfeder Nov 5, 2025

Choose a reason for hiding this comment

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

Rather than reusing the make_executables function, constructing the wrong data structure, and then unwrapping it to make the updates to correct it, it seems to me like it would be cleaner to factor out the logic that produces the wrapped record Per_stanza record, then down on lines 563 and 564, have

         | Executables.T exes -> `Executables (make_per_stanza ~dir ~expander ~modules ~project exes)
         | Tests.T tests -> `Tests (make_per_stanza ~dir ~expander ~modules ~project tests)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think that would be sensible if tests stanzas were a lot more different than the executables stanza, but they are really the same with one extra piece of data. The way everything is laid out means its tricky to reuse stuff due to the polymorphism. I reckon the whole thing could be ripped apart and better data structures introduced, but that's out of scope for this PR.

If you however see a way to do it, and it doesn't introduce a lot of one time used functions in the file I would be open to it, but at this point its not clear to me.

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.

3 participants