Skip to content

ocamltest: add an 'ocamltest' action to test ocamltest#13317

Merged
gasche merged 1 commit intoocaml:trunkfrom
gasche:test-ocamltest
Jan 28, 2026
Merged

ocamltest: add an 'ocamltest' action to test ocamltest#13317
gasche merged 1 commit intoocaml:trunkfrom
gasche:test-ocamltest

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Jul 18, 2024

This is part of #13315, split out for easier reviewing. It adds an ocamltest; action in ocamltest, which allows to test ocamltest scripts. This sounds like a generally useful feature that I think we should integrate no matter what happens to #13315.

For example, suppose I want to test that the not <test>; feature from #13315 works properly. I write the following test script:

(* TEST
{ not pass; fail; }
{ not skip; pass; }
*)

The problem is that if I just add this to the testsuite, I will see that this test script succeeds, but I don't know if the feature works as intended. Maybe not foo; always skips, and therefore this test passes without doing what I think it does. I can check that this does not happen myself, by tweaking the test to say { not skip; fail } instead of { not skip; pass }, and checking that that fails. But I cannot commit this to the testsuite. How do I leave evidence in the testsuite that the pass action after the not skip indeed runs?

My solution is that instead of writing this as a negation.ml test, called with the usual driver, I write my test above as a negation.test file, with a semantics.ml driver test that reads as follows:

(* TEST
{
  readonly_files="negation.test negation.reference";
  program="negation.test";
  output="negation.result";
  flags="-e";
  ocamltest;
  reference="negation.reference";
  check-program-output;
}
*)

And then in negation.reference I put the result of running ocamltest -e negation.test, which is mostly unreadable but changes if I change the test or the not implementation. At this point I'm happy.

Result.skip_with_reason "ocamlobjinfo not available", env
)

let ocamltest_action log env =
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.

Note for reviewers: to review this, just compare to the mklib stuff below -- on the github interface this requires expanding the diff a bit.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Mar 18, 2025

This is a simple PR and I wish something would help by reviewing, as it could unblock further contributions to ocamltest. Maybe @OlivierNicole?

@nojb
Copy link
Copy Markdown
Contributor

nojb commented Mar 18, 2025

I will review this today.

Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

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

LGTM

Would you mind adding a simple test of the new action just to illustrate concretely how it is used? Thanks!

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Jan 28, 2026

I have decided to restart working on negation in ocamltest (a new version of #13315 with only not foo; and without the conditional syntax), and having this PR merged would help. I decided to go ahead and merge this. For the usage example suggested by @nojb, I propose to look at 2e22237 for the time being.

@gasche gasche merged commit 646341b into ocaml:trunk Jan 28, 2026
@gasche
Copy link
Copy Markdown
Member Author

gasche commented Feb 1, 2026

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.

3 participants