Skip to content

Commit dbd498c

Browse files
authored
Tests: reset .ocamlformat using profile=default (#2124)
Dune 2 and dune 3 implement cram tests slightly differently. In dune 3, a `.git` directory is added so that executables that rely on git work properly. Without this (in dune 2), ocamlformat walks up the directory structure and applies 2 files: the `.ocamlformat` file at the project root (the one used for ocamlformat itself) and the empty ones that are touched in each cram test. Merging this is equivalent to the exterior one. In dune 3, only the empty one is used. This makes a difference in the `repl_file_errors.t` test. The dune 3 behavior is the intended one. This commit fixes the "reset" strategy to use instead `profile=default` (which will properly override the external file) and makes the test suite compatible with dune 2 and dune 3.
1 parent fd908d7 commit dbd498c

File tree

11 files changed

+10
-15
lines changed

11 files changed

+10
-15
lines changed

Diff for: dune-project

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
(cmdliner
4141
(>= 1.1.0))
4242
dune
43-
(dune
44-
(and
45-
:with-test
46-
(< 3.0)))
4743
dune-build-info
4844
either
4945
fix

Diff for: ocamlformat.opam

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ depends: [
1313
"base" {>= "v0.12.0"}
1414
"cmdliner" {>= "1.1.0"}
1515
"dune" {>= "2.8"}
16-
"dune" {with-test & < "3.0"}
1716
"dune-build-info"
1817
"either"
1918
"fix"

Diff for: test/cli/bad_kind.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ echo 'module X : S' > a.mli
44

Diff for: test/cli/check.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ echo 'let x = 1' > a.ml
44
$ ocamlformat --check a.ml

Diff for: test/cli/debug.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ cat > a.ml << EOF
44
> (* Intentionally not formatted *)

Diff for: test/cli/deprecated_option.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ echo 'let x = y' > a.ml
44

Diff for: test/cli/large_string.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ echo "let _ = \"$(printf '%*s' 300000 | sed 's/ /_ _/g')\"" > a.ml
44

Diff for: test/cli/max_iters.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ echo 'let x = 1' > a.ml
44
$ ocamlformat --max-iters=1 a.ml

Diff for: test/cli/name.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
$ echo 'let x = 1' > a.ml
44
$ ocamlformat --name a.cpp a.ml

Diff for: test/cli/repl_file_errors.t/run.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
Make sure the locations of errors in repl files are right.
44

@@ -27,5 +27,5 @@ Make sure the locations of errors in repl files are right.
2727
[1]
2828

2929
$ ocamlformat --repl-file empty_line_begin.repl
30-
# foo bar ;;
30+
# foo bar;;
3131
- : 0

Diff for: test/cli/stdin.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ touch .ocamlformat
1+
$ echo profile=default > .ocamlformat
22

33
One of '--impl', '--intf' or '--name' is required when the input is read from stdin:
44

0 commit comments

Comments
 (0)