Skip to content
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

Clean up end-to-end testing #178

Merged
merged 6 commits into from
Oct 7, 2019
Merged

Conversation

craigfe
Copy link
Contributor

@craigfe craigfe commented Sep 19, 2019

This cleans up the end-to-end test plumbing:

  • it categorises the tests according to the feature-under-test, rather than managing all of the tests in the same dune file;

  • it splits up test files that were being used to test multiple features (in particular, section.md has been gradually accumulating more responsibilities... see #161 and #167);

  • it adds a new gen_dune_rules.ml executable responsible for generating some of the more common patterns. This picks up any test-specific CLI options from <test>.opt files;

  • it adds runtest triggers for .md files that were previously being ignored (e.g. environment_variable.md). The introduction of the auto-generation script prevents this problem from re-occurring in the future.

This is based on #177 (unmerged) for convenience, and also tests the new functionality in that PR via the test_fixpoint/cram test case.

test/dune Show resolved Hide resolved
@craigfe
Copy link
Contributor Author

craigfe commented Sep 20, 2019

Rebased over #171.

@craigfe
Copy link
Contributor Author

craigfe commented Sep 20, 2019

Rebased over #163.

test/bin/gen_dune_rules.ml Outdated Show resolved Hide resolved
test/bin/gen_dune_rules.ml Outdated Show resolved Hide resolved
test/bin/gen_dune_rules.ml Show resolved Hide resolved
@Julow
Copy link
Collaborator

Julow commented Sep 20, 2019

I add the tests from #172 in craigfe#1

@craigfe craigfe force-pushed the refactor-tests branch 2 times, most recently from 1d4b9b3 to c0186c7 Compare September 20, 2019 16:09
craigfe and others added 2 commits October 3, 2019 23:56
Co-authored-by: Jules Aguillon <juloo.dsi@gmail.com>
@craigfe
Copy link
Contributor Author

craigfe commented Oct 3, 2019

Rebased.

@craigfe
Copy link
Contributor Author

craigfe commented Oct 4, 2019

CI failing for unrelated reasons; can't re-trigger it myself.

@Julow
Copy link
Collaborator

Julow commented Oct 4, 2019

Restarted it and it's passing.

test/bin/gen_dune_rules.ml Outdated Show resolved Hide resolved
test/bin/gen_dune_rules.ml Outdated Show resolved Hide resolved
let options = options_of_file file in
let command =
let args = file::options in
Fmt.strf "ocaml-mdx rule %a" pp_options args
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is calling ocaml-mdx I have on my system if I dune clean. You should add (package mdx) on every rules calling this program.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks 🙂 It's only necessary in the test_fixpoint/dune case, since other rule generation patterns don't rely on ocaml-mdx rule. Have added it there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not super convinced by this one. I feel like we should either test ocaml-mdx test or ocaml-mdx rule but not both at the same time.

If I want to test ocaml-mdx rule, I will compare its output with a .expected file.

None of the tests in test_fixpoint actually require calling ocaml-mdx rule and this could just be another case of test_expect from what I can see. I might be wrong so let me know if it is in fact required but if it's not, I think we could detect whether the .expected file exists and compare to input on if it doesn't!

Copy link
Contributor

Choose a reason for hiding this comment

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

Another advantage of my suggested approach is that we'd get rid of the annoying execvp errors!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding testing ocaml-mdx rule separately: I agree completely, but think this is something we should do next. The test directories are structured so that a test/rule_expect will fit in there nicely. The current state of affairs is how it was being done before, and I kept it this way to keep the diff smaller (not introducing a bunch of additional tests in the middle of a refactor).

Regarding making test_fixpoint a conditional behaviour of test_expect in the case where the expected file doesn't exist: I'd rather not do this. I'd rather the behaviour was kept explicit, and that each test_foo be kept as simple as possible. The code can be simplified in another way by testing ocaml-mdx rule generation separately and then not depending on ocaml-mdx rule to generate tests of other properties of the binary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree about keeping the behaviour explicit!

My main point was that I think you could just make the current test_fixpoint_rule very similar to test_expect_rule. I agree it changes how things were done but I don't think it will change what's tested too much and we could add proper ocaml-mdx rule tests in a separate PR.

Let's merge it like this, I'll improve it later on, you already had to rebase this quite a few times by now!

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.

Can be merged.

@Julow Julow requested a review from NathanReb October 4, 2019 14:05
Copy link
Contributor

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

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

This is amazing work, thank you very much @craigfe, those test needed some polishing!

I have a few comments about the current implementation but nothing major.

Another thing I'd like to go is to go even further and move each test case-ish to a separate subfolder to avoid having test files depend on each other which is still the case currenlty. We can take care of that separately!

test/bin/gen_dune_rules.ml Outdated Show resolved Hide resolved
test/bin/test_expect/dune Outdated Show resolved Hide resolved
let options = options_of_file file in
let command =
let args = file::options in
Fmt.strf "ocaml-mdx rule %a" pp_options args
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not super convinced by this one. I feel like we should either test ocaml-mdx test or ocaml-mdx rule but not both at the same time.

If I want to test ocaml-mdx rule, I will compare its output with a .expected file.

None of the tests in test_fixpoint actually require calling ocaml-mdx rule and this could just be another case of test_expect from what I can see. I might be wrong so let me know if it is in fact required but if it's not, I think we could detect whether the .expected file exists and compare to input on if it doesn't!

let options = options_of_file file in
let command =
let args = file::options in
Fmt.strf "ocaml-mdx rule %a" pp_options args
Copy link
Contributor

Choose a reason for hiding this comment

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

Another advantage of my suggested approach is that we'd get rid of the annoying execvp errors!

Co-authored-by: Jules Aguillon <juloo.dsi@gmail.com>
Co-authored-by: Nathan Rebours <nathan.p.rebours@gmail.com>
Copy link
Contributor

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

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

Let's merge!

@NathanReb NathanReb merged commit 6f528b5 into realworldocaml:master Oct 7, 2019
@craigfe craigfe deleted the refactor-tests branch October 7, 2019 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants