Skip to content

Add a few more tests in anticipation of fixes #1079

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

Merged
merged 7 commits into from
Mar 7, 2024

Conversation

jonludlam
Copy link
Member

This includes some changes to odoc_print. We might want to change some more tests to use this rather than jq.

@jonludlam
Copy link
Member Author

Oh hang on, this needs a fix or two.

@jonludlam jonludlam force-pushed the more-tests branch 2 times, most recently from 75e8f99 to 6007fe0 Compare February 8, 2024 16:30
@jonludlam jonludlam added the no changelog This pull request does not need a changelog entry label Feb 8, 2024
@jonludlam
Copy link
Member Author

OK that looks better!

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

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

The new output looks really nice and eliminate the jq queries that could easily break with changes in Lang.


let a_show_canonical =
let doc = "Show modules canonical reference in short output" in
Arg.(value & flag & info ~doc [ "show-canonical" ])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This options seems unused. Why shouldn't it be true by default ?


let a_show_removed =
let doc = "Show removed items in signature expansions in short output." in
Arg.(value & flag & info ~doc [ "show-removed" ])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one also seems unused. I think it should be true by default, the output of the tests wouldn't be changed currently.


let a_long_paths =
let doc = "Show long paths in short output" in
Arg.(value & flag & info ~doc [ "long-paths" ])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This option isn't used. What's its use case ?


let a_show_include_expansions =
let doc = "Show include expansions in short output" in
Arg.(value & flag & info ~doc [ "show-include-expansions" ])
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the inconvenient in merging this option with --show-expansions ? The output is quite short already.

@@ -0,0 +1,13 @@
#!/bin/sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I said in #1042, this test is not portable and is annoying to work with due to many files and the scripts. Here's an alternative that should be more portable and is easier to read and change: jonludlam#43

Copy link
Member Author

Choose a reason for hiding this comment

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

I find your version slightly less readable, and it's also more tricky to try outside of 'dune runtest'.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Trying outside of dune runest is not a goal of cram tests. Perhaps the test should exist in two different forms.
Why is it less readable ? It contains basically the same code but with 90% of it removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer my tests to be very explicit and clear, and your version, to me, obfuscates it with the source on one line with shell variable substitution going on. Please can we leave it as it is, and if you have any problems maintaining the test just punt it to me :-D

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, let's leave it as it is.

if c.short_paths then Format.fprintf ppf "%a" (fn1 c) x
else Format.fprintf ppf "%s(%a,%a)" txt (fn1 c) x (fn2 c) y

let wrap2r :
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit worried about the added maintenance in this module. Component changes often and the printing functions are slowing down other work.
These functions need some documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true, I'll add some doc comments.

@jonludlam
Copy link
Member Author

Mostly the extra options were those that were either useful while debugging or I anticipate will be useful in replacing the jq test cases. The marginal cost of adding extra params is dwarfed by the cost of introducing any params at all so I figured I might as well have a few in there now to make the later conversion of tests easier. In addition the defaults are chosen so that 'short' output is shortest!

@Julow
Copy link
Collaborator

Julow commented Feb 27, 2024

I think the many options can be surprising while writing tests. What do you think of removing --show-include-expansions ?

@jonludlam
Copy link
Member Author

I kept the 'show-include-expansions' separate from the 'show-expansions' as this is required to show the complete contents of a module, whereas the 'show-expansions' will show everything within the signature, including all submodules. I found this useful particularly when comparing the output with ocamlc -i

Copy link
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

Looks good to me.

The maintenance cost of all those printing function is still heavy but not that much heavier than today, and the output in tests is much nicer.

I'm fine with the tests and the unused commands.

Fix typo

Co-authored-by: panglesd <peada@free.fr>
@jonludlam jonludlam merged commit 3ed9049 into ocaml:master Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog This pull request does not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants