-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new [%%expect_in <version-range> {| ... |}]
syntax for expect tests and fix 5.3 builds
#539
Conversation
Signed-off-by: Nathan Rebours <[email protected]>
Signed-off-by: Nathan Rebours <[email protected]>
Signed-off-by: Nathan Rebours <[email protected]>
Signed-off-by: Nathan Rebours <[email protected]>
aa25093
to
9cb1df4
Compare
Signed-off-by: Nathan Rebours <[email protected]>
Signed-off-by: Nathan Rebours <[email protected]>
I found a nicer fix for the quoter tests. The large AST values that were printed were just a side effect and not the actual test. That's because our expect runner did not offer a way not to see the toplevel output for a select set of phrases. I added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @NathanReb -- this is a super useful fix which I'm sure we'll use a lot. One thought about the syntax (i.e. not blocking the PR at all!) was maybe we could match opam
and dune
's syntax for expressing version constraints. This means
[%%expect_in 5.3 +
could become[%%expect_in >= 5.3
[%%expect_in 5.2 <
could become[%%expect_in <= 5.2
- between could stay the same otherwise we need
&&
or something...
I do like your syntax too in terms of not suggesting we support <
and >
as well!
Whatever you think :))
(* Entrypoint | ||
Parses blocks of code to execute seperated by [%%expect{|...|}] statement. | ||
Code blocks can be separated by a single [%%expect{|...|}] statement or by a | ||
series of [%%expect_in <version-range> {|...|}]. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a comment that the expectation is the combination of ranges should cover the ranges for which the test will be run against -- I had initially thought we would have some kind of implicit ignore
if a version was not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a good point, I'll change that!
The idea for not ignoring the output for versions not covered by the union of ranges was that we should try and run our tests for all versions as much as possible and that tests that absolutely don't work on certain versions should probably not be run for those at all. This will force us to isolate such tests.
Yes I think I'd rather not add something like I'm happy to switch to a more commonly used syntax though and use Even though I prefer the interval notation I do agree consistency is probably the best here. For the interval we could maybe do something like |
Signed-off-by: Nathan Rebours <[email protected]>
Just pushed the changes in the latest commit if you want to take a look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome :))
This adds a new syntax for expect tests where code can be followed by multiple
[%%expect_in <version-range> {| ... |}]
instead of a single[%%expect{|...}|]
.E.g. in the following example:
Depending on the compiler version, one of these blocks will be copied from the source file while the other one will be filled with the toplevel evaluation outcome of
let x = 2
.Meaning if we run this test in 5.2, it will pass, while if we run it in 5.3, we'd get the following:
I've also proceeded to use this to fix the test for 5.3. The ones in
metaquot
andcode_path
look good to me as they are caused by changes in the compiler and how functor signatures and type aliases are printed out.The one in
quoter
I'm not quite sure what to do with it as the original test is not very good, it's extremely hard to read the output and make out what's supposed to happen there.I'm happy to split the test fixes with the new expect test feature but though it would be good to show they work!