makefile rule to test parser changes by comparing ASTs stored in .ml.ast files#2030
makefile rule to test parser changes by comparing ASTs stored in .ml.ast files#2030gasche merged 2 commits intoocaml:trunkfrom
.ml.ast files#2030Conversation
|
Proposed (and tested) workflow: (Edit: see below for more recent workflow.) # save pre-change ASTs
make -j build-all-asts
find . -name '*.ml.ast' | xargs git add
# do your parser changes
# ...
make promote-menhir
# compare new ASTs
make -j build-all-asts
git diff # shows any .ml.ast difference
# remove AST files
find . -name '*.ml.ast' | xargs git reset HEAD
find . -name '*.ml.ast' | xargs rm |
|
Should we be checking in the old .ast file into the repository and having a formal test? Then it would be easy to make changes. If you meant for the .ast file to change, you would of course modify it as part of your updates. |
|
I would rather not, because source files change frequently and I believe this would cause too much churn to be comfortable. (In the world of git, reviewing and managing the list of changing files are common operations; doubling the number of changed files would have a large usability cost.) |
Makefile
Outdated
|
|
||
| # Testing the parser -- see parsing/HACKING.adoc | ||
|
|
||
| SOURCE_ML_FILES=$(shell git ls-files | grep '\.ml$$') |
There was a problem hiding this comment.
can replace this by $(shell git ls-files *.ml)
There was a problem hiding this comment.
I tried git ls-files *.ml in my terminal and it doesn't work, but now that you say it git ls-files '*.ml' does work -- I guess you have to present the shell from globbing the argument first. I will change this, thanks!
parsing/HACKING.adoc
Outdated
| describing the parsed abstract syntax tree (AST) in `-dparsetree` | ||
| format. | ||
|
|
||
| This rule is rather slow to run, and can safely be run in paralle, so |
|
I decided to extend |
bc0db71 to
e024eee
Compare
|
@nojb: I applied your comments, added |
|
Sounds cool, very useful! |
|
With the # save pre-change ASTs
make -j build-all-asts
make list-all-asts | xargs git add
# do your parser changes
# ...
make promote-menhir
# compare new ASTs
make -j build-all-asts
git diff # shows any .ml.ast difference
# remove AST files from the index
make list-all-asts | xargs git reset HEAD
# remove the files (if no further parser change planned)
make list-all-asts | xargs rm |
|
|
||
| SOURCE_FILES=$(shell \ | ||
| git ls-files '*.ml' '*.mli' \ | ||
| | grep -v '^experimental/') |
There was a problem hiding this comment.
Off-topic in this PR, but I wonder if there is a good reason to keep this in the tree nowadays.
There was a problem hiding this comment.
I will send a PR to remove it. (Would you by chance 'approve' of the present one?)
There was a problem hiding this comment.
IIRC @shindere tried to remove things from experimental but some of the owners of those files pushed back. Maybe it's time to apply more pressure.
There was a problem hiding this comment.
In fact, experimental was completely removed in da5c22a
|
Thanks! Merged. |
See #2029: