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

Improve: simplify makefile #973

Merged
merged 6 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
/ocamlformat.install
/ocamlformat_reason.install
/src/mod_dep.dot
/test/code
/test-extra/code
/test-extra/bisect*out
/test/bisect*out
/bisect*out
/_coverage
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Once OCamlFormat has been built, run `make test` to check for regressions.

The first step of `make test` is to ensure that invoking OCamlFormat on its own source code produces the same source code (you can run `make fixpoint` to only check this). If OCamlFormat is not integrated with the editor you use, you should run `make fmt` to reformat all OCamlFormat source files.

The second part of `make test` is to ensure the test suite passes, the test report is displayed in the terminal and you should only get `[FAILED] [BASELINE]` (in orange) results. You should not get any result in red nor any `[REGRESSION]`.
The second part of `make test` is to ensure the test suite passes. You should not see any unexpected diff. One can accept all diffs at once with `make regtests-promote`.

Once `make test` passes, pull requests should be tested on the code in a set of external repositories. This can be done by executing `tools/test_branch.sh <rev>` where `<rev>` is the git revision/branch containing the pull request's changes. If a pull request affects an option, `OCAMLFORMAT=<option>=<value> tools/test_branch.sh <rev>` should also be run to test with the option enabled.

Expand Down
50 changes: 17 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,12 @@ setup: dune-workspace

.PHONY: exe
exe: setup
dune build _build/dev/src/ocamlformat.exe _build/release/src/ocamlformat.exe _build/dev/ocamlformat.install _build/release/ocamlformat.install
dune build _build/dev/src/ocamlformat.exe _build/release/src/ocamlformat.exe

.PHONY: gen-help
gen-help:
dune build _build/release/ocamlformat-help.txt

.PHONY: bc
bc: setup
dune build _build/dev/src/ocamlformat.bc

.PHONY: dev
dev: setup
dune build _build/dev/src/ocamlformat.exe _build/dev/ocamlformat.install

.PHONY: opt
opt: setup
dune build _build/release/src/ocamlformat.exe _build/release/ocamlformat.install

.PHONY: reason
reason: setup
dune build _build/dev/src/ocamlformat_reason.exe _build/release/src/ocamlformat_reason.exe
Expand All @@ -59,30 +47,26 @@ SRCS=$(shell \find src tools -name '[^.]*.ml' -or -name '[^.]*.mli' -or -name '[

.PHONY: fmt
fmt:
$(shell \ls -t _build/*/src/ocamlformat.{exe,bc} | head -1) -i $(SRCS)
dune exec --context dev -- ocamlformat -i $(SRCS)

.PHONY: test regtests fixpoint test-reason
test: fixpoint regtests

.PHONY: test
test: exe reason
$(MAKE) fixpoint
$(MAKE) regtests
fixpoint: setup
dune exec --context dev -- ocamlformat -n 1 -i $(SRCS)

.PHONY: test-reason
test-reason: reason
dune build _build/dev/test/reason/test-gen.ml --auto-promote
regtests: setup
dune build @_build/dev/test/runtest

.PHONY: regtests fixpoint
fixpoint: exe reason
_build/release/src/ocamlformat.exe -n 1 -i $(SRCS)
regtests-promote: setup
dune build @_build/dev/test/runtest --auto-promote

regtests: exe
dune build @_build/dev/test/disabled/runtest
$(MAKE) -C test regtests
test-reason: setup
dune build @_build/dev/test/reason/runtest-reason --auto-promote

.PHONY: coverage
coverage: setup
dune build _build/coverage/src/ocamlformat.exe
$(MAKE) cleanbisect
$(MAKE) MODE=coverage -C test regtests
_build/coverage/src/ocamlformat.exe -i $(SRCS)
bisect-ppx-report -I _build/coverage/ -html _coverage/ `find test -name 'bisect*.out'`
coverage: setup cleanbisect
dune build @_build/coverage/test/runtest
dune exec --context coverage -- ocamlformat -i $(SRCS)
bisect-ppx-report -I _build/coverage/ -html _coverage/ `find ./ _build/coverage/ -name 'bisect*.out'`
@echo "open _coverage/index.html"
2 changes: 2 additions & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
(deps ./src/ocamlformat.exe)
(mode promote)
(action (with-stdout-to %{targets} (run ./src/ocamlformat.exe --help=plain))))

(data_only_dirs test-extra)
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 1.1)
(lang dune 1.11)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
Expand Down
2 changes: 1 addition & 1 deletion ocamlformat.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ depends: [
"base-unix"
"bisect_ppx"
"cmdliner"
"dune" {>= "1.1.1"}
"dune" {>= "1.11.1"}
"fpath"
"ocaml-migrate-parsetree" {>= "1.3.1"}
"odoc" {>= "1.4.1"}
Expand Down
2 changes: 1 addition & 1 deletion ocamlformat_diff.opam
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build: [
depends: [
"bos"
"cmdliner"
"dune" {build & >= "1.1.1"}
"dune" {build & >= "1.11.1"}
"ocamlformat"
]
synopsis: "OCamlFormat diff tool"
Expand Down
3 changes: 1 addition & 2 deletions ocamlformat_reason.opam
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ depends: [
"base-unix"
"bisect_ppx"
"cmdliner"
"dune" {>= "1.1.1"}
"dune" {>= "1.11.1"}
"fpath"
"ocaml-migrate-parsetree" {>= "1.0.10"}
"odoc" {>= "1.4.1"}
Expand All @@ -37,4 +37,3 @@ build: [
dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git"
synopsis: "Auto-formatter for ReasonML code"
description: "ocamlformat_reason is a tool to automatically format ReasonML code in a uniform style."

5 changes: 0 additions & 5 deletions test/Makefile → test-extra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,3 @@ clean_pp:

print-%:
@echo '$*=$($*)'

.PHONY: regtests
regtests:
@echo running regtests with $(OCAMLFORMAT_EXE)
@dune runtest
1 change: 0 additions & 1 deletion test/dune

This file was deleted.

1 change: 0 additions & 1 deletion test/failing/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

(alias
(name runtest)
(enabled_if (= %{context_name} "dev"))
(deps list_and_comments.ml.broken-ref list_and_comments.ml.output)
(action (diff list_and_comments.ml.broken-ref list_and_comments.ml.output)))
1 change: 0 additions & 1 deletion test/passing/dune
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ let emit_test buffer test_name setup =

(alias
(name runtest)
(enabled_if (= %%{context_name} "dev"))
(deps %s %s.output)
(action (diff %s %s.output)))
|}
Expand Down
4 changes: 4 additions & 0 deletions test/reason/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
(targets test-gen.ml)
(mode promote)
(action (run %{bin:ocamlformat_reason} %{dep:test-bin.re} -o %{targets})))

(alias
(name runtest-reason)
(deps test-gen.ml))
1 change: 0 additions & 1 deletion test/reason/test-gen.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(* test *)

let x = 3

type schoolPerson = Teacher | Director | Student of string
Expand Down
4 changes: 2 additions & 2 deletions tools/test_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ base=$(git merge-base master $branch)

git checkout $base
make
OCAMLFORMAT="$2" make -C test test_setup test_unstage test_clean test_pull test test_stage
OCAMLFORMAT="$2" make -C test-extra test_setup test_unstage test_clean test_pull test test_stage
git checkout $branch
make
OCAMLFORMAT="$3" make -C test test test_diff
OCAMLFORMAT="$3" make -C test-extra test test_diff