-
Notifications
You must be signed in to change notification settings - Fork 414
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
Diffing and promoting multiple files #3567
Comments
BTW, have you tried using multiple rules with one |
Can't this be addressed by writing an individual rule for every |
Indeed. However, before I needed the execution of another command that was generating the files to compare: (test
(name test)
(libraries alcotest unix)
(deps
(glob_files inputs/*.*)
)
(action
(progn
(with-accepted-exit-codes (or 0 1) (run %{test} -e)) ; continue diff, especially if test failed
(no-infer (progn
(expected/lex/actor.lex obtained/lex/actor.lex)
(expected/lex/basic.lex obtained/lex/basic.lex)
(expected/lex/cover.lex obtained/lex/cover.lex)
))
)
)
) The workaround was to:
Which gives something like: (executables
(names test)
(libraries alcotest unix)
)
(rule
(target test_run.out)
(deps
(glob_files inputs/*.*)
)
(action (progn
(with-accepted-exit-codes (or 0 1) (run %{dep:test.exe} -e)) ; continue diff, especially if test failed
(write-file %{target} "Test Run")
))
)
(rule
(alias runtest)
(deps test_run.out)
(action (no-infer
(diff expected/lex/actor.lex obtained/lex/actor.lex)
))
)
(rule
(alias runtest)
(deps test_run.out)
(action (no-infer
(diff expected/lex/basic.lex obtained/lex/basic.lex)
))
)
(rule
(alias runtest)
(deps test_run.out)
(action (no-infer
(diff expected/lex/cover.lex obtained/lex/cover.lex)
))
) It's working but lot of duplicate code. It would be nice to have a way to declare a function or macro (like in Shell, Jinja2 Macro, or Makefile) => maybe I could record an enhancement issue :) Merci Jeremy! |
Derien Jeff :)
Yes, that would be nice indeed. We have been talking about this for a while. We kind of don't want to design a bad programming language though. We are hopping to be able to use plain OCaml to factorise |
You mean like being able to call OCaml functions from dune? |
We are not completely sure of the details yet, but if you use complex logic to produce the dune files, it feels like this logic should be written in OCaml rather than a made-up language we invented. |
We're also interested to have multiple files diffing / promotion for building Coq. Here are more details about our use case: We've got a tool called Currently, our Dune rules for this are:
First, as you can see, we could do some serious simplification in the list of dependencies if we had recursive globs (#1866). Then, you can notice the two cc @jfehrle FYI |
Indeed, that doesn't seem ideal. If we had #3668, you could use the "generate and commit" method to avoid having to maintain the boilerplate by hand. Like what we do in Apart from that, recursive globs would indeed help. Another thing we have been talking in the past is to add the ability for commands to talk to the build system. For instance, it seems quite easy to allow commands to dynamically generate |
Note that the tool does consistency checks across the .rst files as a whole to identify missing and duplicated items. Perhaps that would have to be a separate step if each .rsts is updated in its own step. |
We recently also encountered a case where we need to diff two dirs. If |
Desired Behavior
I'm writing some ("custom") tests run with dune and want naturally to use
dune promote
to update my expected results (which are stored in external files as my tested libraries are generated files).As I have several files, I am currently doing the following:
And this file is updated by a script (to be changed by creating an executable to update it).
One limitation is that if many files differ, we need to promote, run the tests again, promote, run ...
The other issue is that
diff
with difference will stop the actions (andwith-accepted-exit-codes
does not supportdiff
).It could be nice to have a way to be able to:
-r
ofdiff
)dune promote --force
)We could also consider a
promote
alias to customize whatdune promote
could do.Examples
We could add either one or both of the following actions:
diffn
anddiffn?
This would be a cross-over between
progn
anddiff
and could be used as such:The main advantage would be to allow promotion of all the differences with a single
dune promote
.If this action is part of
progn
, we would continue to the next action only if no difference has been found.diffd
This action would compare directories but there would be no inference of targets (so no need to have
diffd?
). We could have something likediffd+
to have recursive differences.It could be used as such:
This could also allow multiple promotion.
Cheers
The text was updated successfully, but these errors were encountered: