Skip to content

ocamltest: refactor run_test_tree#13316

Merged
gasche merged 4 commits intoocaml:trunkfrom
gasche:refactor-ocamltest-run
Oct 1, 2024
Merged

ocamltest: refactor run_test_tree#13316
gasche merged 4 commits intoocaml:trunkfrom
gasche:refactor-ocamltest-run

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Jul 18, 2024

This is a fragment of #13315, separated out for easier reviewing: this is just a simple refactoring and anyone is free to have a look.

run_test_tree is the core function of ocamltest that executes a test.

Justification for the change: I want to implement support for <stmts>; !{ ... }, which should execute { ... } if one of the statements in <stmts> skips. Determining this -- whether one of the statement skips -- is not possible/easy with the current structure of run_test_tree, and it is very easy with the new proposed structure.

The PR is split as three small commits, it is easier to review it commit-by-commit (but maybe not too hard to review in bulk as well).

Comment on lines +154 to +156
List.fold_left join_summaries summ
(List.map (run_tree behavior env All_skipped) subs)
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.

A candidate for List.fold_left_map?

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.

Meh, fold_left_map returns a list of results that we don't need, and it expects the function to return a pair which we don't do, so I think the result would be less readable than the current approach.

Comment on lines 48 to 50
let rec concatmap f = function
| [] -> []
| x::xs -> (f x) @ (concatmap f xs)
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.

This exists now, it's List.concat_map.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Jul 19, 2024

@MisterDA if you want to ask me for more refactoring work than what I need, you need to pay me with a full review :-)

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Jul 24, 2024

@MisterDA volunteered to review this.

Copy link
Copy Markdown
Member

@Octachron Octachron left a comment

Choose a reason for hiding this comment

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

I am ok with decoupling the statement evaluation from the traversal logic.

@gasche gasche force-pushed the refactor-ocamltest-run branch from 51f6364 to 8b9c066 Compare October 1, 2024 13:24
@gasche gasche added the merge-me label Oct 1, 2024
@gasche gasche merged commit 9b6f7c3 into ocaml:trunk Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants