Conversation
|
Thanks a lot @gasche.
Busy with other things at themoment, I hope to come back to this from
August 19th onwards if no one else did so until then.
|
|
Gentle ping: I have split two smaller PRs from this PR. (The commits are included there and also here, so reviewing them first is easier.)
|
54622bb to
4a396c9
Compare
4a396c9 to
78c8e86
Compare
|
Hello, this is on my review list but it’s taking me time to get there. If someone else wants to review these first, feel free, just please let me know so we don’t duplicate work. |
|
I remain interested in having someone review this. @OlivierNicole, if you are not available for an implementation review (which I can very well understand), I would still be interested in your opinion on the proposed design, which I think you could form more easily. (Maybe @lukemaurer has an opinion as well as this is tangentially related to #13259.) If there is consensus among ocamltest users that this is a reasonable feature to have, I can probably find someone else that cares less about ocamltest and somehow extract an implementation review out of them. |
|
I rephrased the original message of this PR to emphasize what new constructs are proposed, with short usage examples. (The previous description, which is kept after that, is more about the history of changes that lead to this proposal, which makes sense in the context of a specific discussion about a slightly different proposal from @OlivierNicole.) |
|
Hmm! Seems useful, though I can see a couple of pitfalls: You could write and then someone adds a new condition somewhere higher in the file, and if I understand correctly, if that new condition fails, you're going to end up running the non-Windows tests on Windows. This suggests introducing an explicit Also if someone writes it will look like |
|
Thanks for the feedback. One difficulty with introducing an |
Hmm ... I had been thinking
Yeah, that seems good. So if the surrounding block is skipped, then the whole |
|
Sorry for the delay in checking out this design.
I am unsure about what is done with the Doing so would avoid the behavior that @lukemaurer finds counter-intuitive (I find it odd, too). It seems to me that it would make the semantics of I guess @lukemaurer’s proposal of having blocks as conditions is even better as it would allow for conjunctions. |
|
I don't mind going with |
|
I started splitting this PR to make progress again, in particular #14502 implements the easy part, which is |
I was inspired by #13248 and a discussion with @shindere, @OlivierNicole, @dra27, @damiendoligez and @Octachron to implement the proposal of @OlivierNicole for negated tests in ocamltest script syntax.
Current state in trunk
Today the syntax of OCaml test is
<statements> <blocks>, where statements look likefoo;and are run in sequence, and blocks look like{ ... }and are run only if the statements pass, and not if they skip or fail.The proposal of @OlivierNicole in #13248 is to add negated sub-tests
!{ ... }that run when the statements skip, instead of passing. In particular,foo; { bar } !{ baz }will runbariffoopassess, andbazif it skips. (It fails iffoofails.)After implementing this I iterated and ended with a different design, with a new construct
not <action>;and proper keywords instead of!for readability:else { ... }, andthen { ... }(wherethencan in fact be omitted).New constructs in this PR
This PR introduces
not <action>;,then {<block>}andelse {<block>}.Sematics of
not <action>;: it runsaction, and skips if the action passes and passes if the action skips.Examples of
not:not-windows;can be written asnot windows;,no-tsancan be written asnot tsan;.Semantics of
then,elseblocks:thenblocks and executeelseblocks (in parallel)thenblocks (in parallel) and skipelseblocks(In particular the semantics of
then { ... }is exactly the same as{ ... }.)For example, the following test (a part of tests/backtrace/backtrace_dynlink.ml):
can be rewritten as:
History of the PR
First iteration
At first I implemented negation as proposed by @OlivierNicole. And then I tried to adapt existing tests to follow this syntax, and sometimes it is nice, for example:
becomes:
which avoids a repetition.
But I also realized that this does not remove the need for
not-windowsas I had hoped, due to the following pattern:which I do not want to convert into the following:
Second iteration
The second step was to introduce an explicit negation for statements (not sub-tests). I could write
!windows;for an action that passes ifwindowsskips and skip ifwindowspasses. But then one can write both!windows;and!{ windows; }(only in some contexts) and they have radically different meanings, which is not nice.So in the end I propose a different syntax, inspired by a proposal by @damiendoligez during lunch:
not foo;for the negation of an action, andelse { ... }for a negated sub-child. I also allowthen { ... }for consistency, but this is optional.The content of this PR
In this PR:
!{ ... }!{ ... }to get a sense of what they look like.!{ ... }byelse { ... }and add support forthen { ... }andnot ...;not-fooandno-baractions from the testsuite withnot fooandnot barinstead. (But for now they remain supported as actions.)(There is one occurrence of
not_macos_amd64_tsanwhich I left around, in part because there is nomacos_amd64_tsanaction today, and in part because replacing this properly would requirenot (macos && amd64 && tsan), ornot { macos; arch_amd64; tsan }, and I don't care to add support for this right now.)The PRs #13316 and #13317 were previously part of the present PR and split off for independent review. #13316 was merged, but #13317 is still waiting for a review. It's a small PR, come on!