-
Notifications
You must be signed in to change notification settings - Fork 413
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
Replace promote actions by diff actions + promote command #421
Conversation
I do like the I'm still a bit confused about what build dependencies |
if promote_mode = Ignore then | ||
| Diff { optional; file1; file2 } -> | ||
if (optional && not (Path.exists file1 && Path.exists file2)) || | ||
Io.read_file (Path.to_string file1) = Io.read_file (Path.to_string file2) then |
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.
Isn't this a bit dangerous? If optional
is false, then it might try to read files that don't exist or were deleted.
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.
That's not specific to diff.When executing an action, we always expect that all the dependencies are present.
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.
Please update the (include jbuild.inc)
example as well. It's still using the old promote action.
Here's another question, that's related to the feature rather than this specific PR. Suppose I'd like to check in generated .ml, .mli files from the ocamlyacc rules, how would I do that? I'd like to reuse the ocamlyacc stanza and perhaps have something like this:
But obviously this doesn't work since the diff stanza has to diff bar.ml in _build and in the source tree. Do I need to write my own custom ocamlyacc rule to make this work? |
It's not specific to diff. Jbuilder always infer most dependencies and targets from the action itself. That why you can just write On the other hand, |
@rgrinberg, yes the case where we just want to commit a generate a file doesn't work well with this PR. We need something different for this case. I think that's ok, these are two different features in the end. For instance, (rule
((promote)
(action (run ocamlyacc ...)))) or we could provide a (ocamlyacc (bar))
(promote (bar.mly)) But we must consider the following:
We should discuss all that in a different PR. |
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.
Sure, we can discuss this later. I prefer the separate promote stanza out of those options. Because it lets you promote targets from rules that you didn't write yourself.
I improved a bit the code and updated the documentation |
; `P {|Considering all actions of the form $(b,(diff a b)) that failed | ||
in the last run of jbuilder, $(b,jbuilder promote) does the following: | ||
|
||
If $(b,a) is present in the source tree but $(b,b) isn't, $(b,b) is |
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.
Is source tree
the right word? a
could be in the build tree
and that would still work.
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.
Maybe "source file" versus "generated file"?
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.
a
could indeed be source file
even if it is not very useful. You don't like build tree
?
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.
I don't understand the difference. All files always end up in the build tree. What is important is whether the files are generated by an explicit rule or where copied as it from the source tree.
Following user feedback, this PR changes the way promotion works. It removes the
promote
andpromote-if
actions as well as the--promote
flags. It adds the following:Diff actions
This PR adds the following two actions:
(diff a b)
: print a diff and fail if the contents ofa
andb
are different(diff? a b)
: same thing but does nothing ifa
orb
doesn't existPromote command
jbuilder promote
is added and it does the following: for every(diff a b)
or(diff? a b)
action that failed in the previous run such thata
is a source file andb
is a generated file, promoteb
toa
.A command line flag
--auto-promote
is also added, which is the same as runningjbuilder promote
manually afterjbuilder
has exited.Usage, for "regular" tests
Usage, for "quine" tests (generating .corrected files)
Other changes
I updated all the tests in jbuilder to use this mechanism