-
Notifications
You must be signed in to change notification settings - Fork 33
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
Some expect tests? #204
Comments
We don't need a ppx I think, we already have printers! Dune expect tests are fairly good already. But I think it's a good idea!
|
Dune expect tests are quite heavyweight compared to ppx_expect, with latter you can have dozens of granular tests in one source file, while with dune expect test you can have only one test output per test, and to have multiple tests you need to create multiple dune rules and that gets pretty verbose. ppx_expect won't become a runtime dependency, tests are easily organized into separate lib. Or you want to have minimal dependency footprint for the library and thus suggest to use dune, which is already a dependency? |
You can have multiple outputs per file, they'll just be concatenated. You can separate them with a printf if you want but there's no inherent need.
And yeah I'd rather avoid heavyweight dependencies even if it's just for testing.
|
I'm currently adding some support for missing cases with option parsing. Looking at current tests with looots of manual I wonder how many contributions in OCaml community were never completed/upstreamed because of "don't bring new dependencies! it's OCaml, we don't have decent stdlib, nor runtime type information/standard derivers, you have to code everything by hand in every project, only hardcore!" principle... |
Hello @Lupus, @c-cube, and team, I've been following this discussion and wanted to share my thoughts and a Firstly, I agree with @Lupus's point about the potential benefits of expect I also understand @c-cube's concerns about introducing heavyweight dependencies In my recent PR #229, I made a small change that affects the generated code. Here's a proposal: For every This approach would allow us to easily see the impact of every PR on the I believe this wouldn't add too much maintenance pressure as updating the tests If this proposal aligns with your vision for the project, I'd be happy to write Looking forward to hearing your thoughts. Thank you! |
Short reply from my phone.
First, improving the testing workflow would be great. Right now it involves fetching a submodule and having protoc in the path, and it's a bit crufty. There are some expect tests already but not for the rpc part. More testing is always good, and I'm open to some testing dependencies as long as it doesn't affect the non testing code (so a expect ppx would be fine if it's not used in the libraries themselves; I find dune cramtests to be enough personally though).
Anyway, thank you for offering to do the hard work! 😁
|
I'm thinking that some expect tests should help with maintaining the
ocaml-protoc
codebase with less effort. At the cost of additional dependency, sayppx_yojson_conv
, we could instrument all of internal representations withyojson_of_t
, and useppx_expect
for tests. You just need to feed a bunch of proto definitions in a form of strings into library bits, get some structures as output, pretty-print them as JSON andppx_expect
will capture them and check that code works in the same way it used to without any hand-writing of unit tests. In my experience expect tests with automatic pretty-printing of internal structures works incredibly well with compiler-kind of projects, whichocaml-protoc
definitely belongs to.The text was updated successfully, but these errors were encountered: