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
Cram stanza #3601
Cram stanza #3601
Conversation
A couple of questions: What happens with something like this:
? i.e. which Is the |
To cut down on the boilerplate, me and @jeremiedimino agreed on a slightly different system. The idea is that we first enable cram tests in the dune-project file:
This will make dune search for To customize the various options of a test, we'll have a cram stanza. For example:
@jeremiedimino I know we discussed an inheritance rule for nested cram stanzas, but I'm not really sure that it's required for v1. Also, it would be adhoc to do it just for cram and not allow this for other stanzas. Shall we just skip it for now? For now the boilerplate isn't a big deal for us since we'll still have @samoht @emillon if the above doesn't work for the tests that you're writing, let us know. |
@rgrinberg we should aim at getting rid of |
@rgrinberg I'll try that and let you know of that goes. thanks! |
@jeremiedimino some issues we need to address:
But we could easily rewrite the above as:
Essentially, any time we want to apply fields to all tests, we just need to put them under
|
7f18c25
to
e566eb1
Compare
@jeremiedimino ready for review. Just to confirm, the As a counter argument, we could turn |
What I had in mind is the following:
means that |
Please also add a documentation page in the manual. You should follow the style of |
@emillon you can try this feature out now. |
@jeremiedimino In the |
@@ -18,7 +18,7 @@ homepage: "https://github.com/ocaml/dune" | |||
doc: "https://dune.readthedocs.io/" | |||
bug-reports: "https://github.com/ocaml/dune/issues" | |||
depends: [ | |||
"dune" {>= "2.6.0"} | |||
"dune" {>= "2.7" & >= "2.6.0"} |
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.
Seems like there's something wonky in how we generate dune constraints.
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.
Indeed
I don't think we decided. But thinking about it, if we match on the full filename, for the recursive scheme we could allow things like this:
which would be equivalent to:
and would avoid the repetition. |
@jeremiedimino I've added some high level documentation. Will document the stanza, once we sort out the last details. By the way, I'm getting some second thoughts about standalone file tests. The reason being is that if you have a set of tests like this:
It becomes too easy for these to observe each other's effects when they run. Worse still, writing something like this is also error prone:
Now the commands in Perhaps we should sandbox such tests by default? Otherwise, I think we should consider getting rid of them as they lead to fragile test suites. |
Sandboxing such tests feels like the right default in any case. So we should do that. |
Did you mean without applies_to? That seems fine to me. Another option is
Would we allow globs? E..g It can be done, but then we'd need to look for cram stanza in every single parent directory of the tests if I'm understanding your proposal correctly. |
Indeed
That's more explicit indeed, however the additional
I don't see why not. However, I'm not too sure about matching of the whole path rather than just the sub-directory. If we match on the whole path, then there is a performance impact; for each test in the hierarchy, we need to match it with all cram stanzas in all parent directories instead of just the current directory.
Yes. But I had in mind to match only on the basenames, which means that you can still compute a single default per directory, which can then be memoized. So it's almost the same cost as the non-recursive version. |
8f8d347
to
8f40638
Compare
@jeremiedimino I've added sandboxing. |
@jeremiedimino I've expanded the documentation. |
@rgrinberg I started to test this in ocamlformat. It looks like this is going to work very well! For now, the tests are executed in a different dune-project, so the following feedback might not apply to all configurations. I tested 8f40638. You can see the diff at https://github.com/ocaml-ppx/ocamlformat/compare/master...emillon:dune-cram?expand=1. I encountered a few bugs:
(note that only (but copying the missing parts make
I'll keep you updated once I have ported more, but so far this looks very promising! |
This seems to be an issue in the master branch. @jeremiedimino perhaps this is related to the
Thanks. Will fix.
Will investigate thanks. We really need better tests for watch mode.
I think it's probably picking the installed binary. @aalekseyev does sandboxing scrub environment variables? |
d0459eb
to
28f1f97
Compare
Weird, I just tried this out in master and I get the same behavior. |
I can reproduce it as well. Passing |
@jeremiedimino I got rid of |
Seems reasonable. |
Allow users to enable cram tests in project files `(cram enable)`. Use `cram` stanza to customize such tests Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
About the size of this change; we know it's going to get in and rebasing it is painful. So I suggest that we proceed as follow:
|
Docs look good BTW :) |
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
Introduce a cram stanza. I'm presenting this PR as WIP to discuss the syntax.
The current stanza looks like this:
This will convert all
.t
files in the directory to individual tests, and all directories containing.t
files into full directory tests.For example:
Will contain 2 tests:
run.t
with no additional dependencies.foo/run.t
which will depend on all the source files insidefoo
.Does that make sense?