Skip to content

Commit

Permalink
Run ocamlformat from build context root
Browse files Browse the repository at this point in the history
This will output errors relative to the correct directory.

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
  • Loading branch information
rgrinberg committed May 27, 2019
1 parent 6504134 commit 588fc2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ unreleased

- Support the `.cc` extension fro C++ sources (#2195, fixes #83, @rgrinberg)

- Run `ocamlformat` relative to the context root. This improves the locations of
errors. (#2196, fixes #1370, @rgrinberg)

1.9.3 (06/05/2019)
------------------

Expand Down
3 changes: 2 additions & 1 deletion src/format_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ let gen_rules_output sctx (config : Dune_file.Auto_format.t) ~output_dir =
; Target output
]
in
Some (Lazy.force ocamlformat_deps >>> Build.run ~dir exe args)
Some (Lazy.force ocamlformat_deps
>>> Build.run ~dir:(Super_context.build_dir sctx) exe args)
else
None
in
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox-tests/test-cases/formatting/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ And fixable files can be promoted:
Promoting _build/default/enabled/.formatted/ocaml_file.ml to enabled/ocaml_file.ml.
Promoting _build/default/enabled/.formatted/reason_file.re to enabled/reason_file.re.
$ cat enabled/ocaml_file.ml
Sys.argv: ../../install/default/bin/ocamlformat --impl ocaml_file.ml --name ../../../enabled/ocaml_file.ml -o .formatted/ocaml_file.ml
Sys.argv: ../install/default/bin/ocamlformat --impl enabled/ocaml_file.ml --name ../../enabled/ocaml_file.ml -o enabled/.formatted/ocaml_file.ml
ocamlformat output
$ cat enabled/reason_file.re
Sys.argv: ../../install/default/bin/refmt reason_file.re
Expand Down

0 comments on commit 588fc2b

Please sign in to comment.