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

Enable/disable bisect_ppx via dune-workspace #3403

Merged
7 commits merged into from
May 6, 2020
Merged

Conversation

stephanieyou
Copy link
Contributor

@stephanieyou stephanieyou commented Apr 20, 2020

#57

Enable bisect_ppx in different build contexts via dune-workspace. Example dune-workspace file would contain (context (default (bisect_enabled true))).

To specify which libraries/executables should be preprocessed with bisect_ppx, add (bisect_ppx) to the stanza, instead of using the (preprocess (pps ...)) field. Example:

(library
  (name foo)
  (bisect_ppx))
(executable
  (name test)
  (libraries foo))

The library foo would be instrumented for bisect_ppx, and the executable test would not be.

@nojb
Copy link
Collaborator

nojb commented Apr 20, 2020

I would be really interested in supporting the same functionality for landmarks, with a similar workflow as bisect_ppx.

Is it possible to make this feature a bit more general?

cc @mlasson

@stephanieyou
Copy link
Contributor Author

stephanieyou commented Apr 20, 2020

I think it would be possible to generalize this PR to add syntax in dune-workspace files like:
(context (default (enable bisect_ppx landmarks)))
and in dune files:

(library
  (name foo)
  (optional_pps bisect_ppx landmarks))
(library
  (name bar)
  (optional_pps bisect_ppx))

The ppx that would actually end up getting used for each library/executable would be the intersection of the enable list from dune-workspace, and the optional_pps list.

That being said, I believe this is meant to be a short-term solution for bisect_ppx before some refactoring gets done and a more permanent solution can be implemented.

cc @diml

@stephanieyou stephanieyou force-pushed the bisect-ppx branch 7 times, most recently from 926718e to 774ba6e Compare April 22, 2020 18:43
@stephanieyou stephanieyou marked this pull request as ready for review April 22, 2020 19:57
@stephanieyou stephanieyou changed the title [WIP] Enable/disable bisect_ppx via dune-workspace Enable/disable bisect_ppx via dune-workspace Apr 22, 2020
@stephanieyou stephanieyou force-pushed the bisect-ppx branch 2 times, most recently from d212acb to 186c886 Compare April 24, 2020 16:30
@ghost
Copy link

ghost commented Apr 28, 2020

Generalising would be nice. However Stephanie will soon be switching project and it feels a bit too late to me to go back and generalise this feature. Additionally, support for bisect is a very long standing feature request and initially all the conversations got stuck into bike shedding because we couldn't find the right generalisation. There is such a thing as "premature generalisation". So for now, let's wrap up bisect support.

FTR, we had the same issue for inline tests. Once we decided to specialise the support for ppx_inline_test, the generalisation became obvious. i.e. it became obvious what was the general structure and what were the configuration bits.

In any case, I'm all for supporting other tools that use similar workflows. So happy to brainstorm about a generalisation after this PR. And if we can't find the right generalisation, then it's only fair that we had similar specific support for landmarks.

src/dune/dune_file.ml Outdated Show resolved Hide resolved
Copy link

@ghost ghost 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, but let's make sure to error out when the user tries to use (bisect_ppx) in combination with (preprocess (action ...)), to avoid surprises.

src/dune/dune_file.ml Outdated Show resolved Hide resolved
test/blackbox-tests/test-cases/bisect-ppx/run.t Outdated Show resolved Hide resolved
test/blackbox-tests/test-cases/bisect-ppx/bisect-exe/dune Outdated Show resolved Hide resolved
Signed-off-by: Stephanie You <youstephanie98@gmail.com>
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Looks all good apart from the extension registration that I missed in the first review

src/dune/dune_file.ml Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Apr 29, 2020

@stephanieyou could you also add an entry in the CHANGES.md file?

@rgrinberg or @aantron, does one of you want to have a quick look at this PR?

@aantron
Copy link
Collaborator

aantron commented Apr 29, 2020

Looks good to me. Usage is:

  1. Add dune-workspace like

    (lang dune 2.5)
    
    (context default)
    (context (default (name coverage) (bisect_enabled true)))
    
  2. Run tester with dune runtest --context coverage

I think it would be best if this didn't require an extra boilerplate file (dune-workspace), and coverage settings properly belong to a project rather than to a workspace, since one is typically trying to instrument a project's code. We can debate/address that in follow-on work, however, like when generalizing for landmarks.

@ghost
Copy link

ghost commented Apr 29, 2020

That's a good point. We initially wanted to add the bisect_enabled setting to the env stanza, but it turned out to be complicated to implement in the current state of the code base.

Signed-off-by: Stephanie You <youstephanie98@gmail.com>
Signed-off-by: Stephanie You <youstephanie98@gmail.com>
Signed-off-by: Stephanie You <youstephanie98@gmail.com>
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Just a couple of suggestions for the manual, but looks all good otherwise!

doc/bisect.rst Outdated Show resolved Hide resolved
doc/bisect.rst Outdated Show resolved Hide resolved
@ghost ghost merged commit b398913 into ocaml:master May 6, 2020
@ghost
Copy link

ghost commented May 6, 2020

Thanks for this work! I'm glad we finally have an answer for users of dune and bisect_ppx :)

@avsm
Copy link
Member

avsm commented May 6, 2020

This is fantastic! Thank you @stephanieyou!

@nojb nojb mentioned this pull request Jun 7, 2020
5 tasks
mefyl pushed a commit to mefyl/dune that referenced this pull request Jul 7, 2020
This pull request was closed.
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.

5 participants