Skip to content

Commit c378059

Browse files
committed
Merge branch 'MAIN' into pr/2715
2 parents 24bb5f4 + 236a5ed commit c378059

File tree

13 files changed

+46
-235
lines changed

13 files changed

+46
-235
lines changed

doc/manpage_ocamlformat.mld

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,16 @@ OPTIONS (CODE FORMATTING STYLE)
471471
Style for function call. The flag is set by default.
472472

473473
OPTIONS (REMOVED)
474-
--align-cases=VAL
474+
--align-cases=VALUE
475475
This option has been removed in version 0.22.
476476

477-
--align-constructors-decl=VAL
477+
--align-constructors-decl=VALUE
478478
This option has been removed in version 0.22.
479479

480-
--align-variants-decl=VAL
480+
--align-variants-decl=VALUE
481481
This option has been removed in version 0.22.
482482

483-
--doc-comments-val=VAL
483+
--doc-comments-val=VALUE
484484
This option has been removed in version 0.16. If you are using
485485
`doc-comments-val=before` in combination with
486486
`doc-comments=before` then only `doc-comments=before` is now
@@ -495,27 +495,27 @@ OPTIONS (REMOVED)
495495
`doc-comments-val=unset` the same behavior can now be achieved by
496496
setting `doc-comments` only.
497497

498-
--escape-chars=VAL
498+
--escape-chars=VALUE
499499
This option has been removed in version 0.16. Concrete syntax will
500500
now always be preserved.
501501

502-
--escape-strings=VAL
502+
--escape-strings=VALUE
503503
This option has been removed in version 0.16. Concrete syntax will
504504
now always be preserved.
505505

506-
--extension-sugar=VAL
506+
--extension-sugar=VALUE
507507
This option has been removed in version 0.17. Concrete syntax will
508508
now always be preserved.
509509

510-
--let-open=VAL
510+
--let-open=VALUE
511511
This option has been removed in version 0.17. Concrete syntax will
512512
now always be preserved.
513513

514514
OPTIONS
515515
Unless mentioned otherwise non-formatting options cannot be set in
516516
attributes or .ocamlformat files.
517517

518-
-c VAL, --config=VAL (absent OCAMLFORMAT env)
518+
-c =[,…], --config==[,…] (absent OCAMLFORMAT env)
519519
Aggregate options. Options are specified as a comma-separated list
520520
of pairs: option=VAL,...,option=VAL.
521521

test/cli/conf.t

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,34 @@ Invalid version:
1313

1414
Exit code is printed by hand because sed succeeding would hide the error.
1515

16-
$ (<a.ml ocamlformat --impl -; echo [$?]) 2>&1 | sed 's/version is "[^"]*"/version is "..."/g'
17-
ocamlformat: Error while parsing $TESTCASE_ROOT/prj/.ocamlformat:
18-
Project should be formatted using ocamlformat version "bad", but the installed version is "..."
16+
$ <a.ml ocamlformat --impl - 2>/dev/null
1917
[1]
2018

2119
Disable version check:
2220

23-
$ (<a.ml ocamlformat --impl --no-version-check -; echo [$?]) 2>&1
21+
$ <a.ml ocamlformat --impl --no-version-check -
2422
let x = "Hello World"
25-
[0]
2623

2724
Invalid syntax in .ocamlformat file:
2825

2926
$ echo 'a = b = c' > .ocamlformat
30-
$ echo 'let x = 1"' | ocamlformat --impl -
31-
ocamlformat: Error while parsing $TESTCASE_ROOT/prj/.ocamlformat:
32-
Invalid format "a = b = c"
27+
$ echo 'let x = 1"' | ocamlformat --impl - 2>/dev/null
3328
[1]
3429

3530
Invalid option:
3631

3732
$ echo 'unknown_option = true' > .ocamlformat
38-
$ echo 'let x = 1' | ocamlformat --impl -
39-
ocamlformat: Error while parsing $TESTCASE_ROOT/prj/.ocamlformat:
40-
Unknown option "unknown_option"
33+
$ echo 'let x = 1' | ocamlformat --impl - 2>/dev/null
4134
[1]
4235

4336
Invalid option (short negated form):
4437

4538
$ echo 'no-wrap-comments' > .ocamlformat
46-
$ echo 'let x = 1' | ocamlformat --impl -
47-
ocamlformat: Error while parsing $TESTCASE_ROOT/prj/.ocamlformat:
48-
Unknown option "no-wrap-comments": "no-wrap-comments" is the short form for "wrap-comments=false". It is only accepted on command line, please use "wrap-comments=false" or "wrap-comments=true" instead.
39+
$ echo 'let x = 1' | ocamlformat --impl - 2>/dev/null
4940
[1]
5041

5142
Invalid value:
5243

5344
$ echo 'field-space = unknown_value' > .ocamlformat
54-
$ echo 'let x = 1' | ocamlformat --impl -
55-
ocamlformat: Error while parsing $TESTCASE_ROOT/prj/.ocamlformat:
56-
For option "field-space": invalid value 'unknown_value', expected one of 'loose', 'tight' or 'tight-decl'
45+
$ echo 'let x = 1' | ocamlformat --impl - 2>/dev/null
5746
[1]

test/cli/dune

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66
(applies_to large_string conf removed_option repl_file_errors debug)
77
(enabled_if
88
(<> %{os_type} Win32)))
9+
10+
; Avoid unstable output from Cmdliner
11+
12+
(env
13+
(_
14+
(env-vars
15+
(TERM dumb))))

test/cli/env.t

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
Invalid option:
22

3-
$ echo 'let x = 1' | OCAMLFORMAT="unknown=true" ocamlformat --impl -
4-
ocamlformat: Error while parsing OCAMLFORMAT environment variable:
5-
Unknown option "unknown"
3+
$ echo 'let x = 1' | OCAMLFORMAT="unknown=true" ocamlformat --impl - 2>/dev/null
64
[1]
75

86
Invalid value:
97

10-
$ echo 'let x = 1' | OCAMLFORMAT="type-decl=unknown" ocamlformat --impl -
11-
ocamlformat: Error while parsing OCAMLFORMAT environment variable:
12-
For option "type-decl": invalid value 'unknown', expected either 'compact' or 'sparse'
8+
$ echo 'let x = 1' | OCAMLFORMAT="type-decl=unknown" ocamlformat --impl - 2>/dev/null
139
[1]

test/cli/removed_option.t

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,11 @@
22

33
Setting a removed option on the command line should display an error message:
44

5-
$ ocamlformat a.ml --extension-sugar preserve
6-
ocamlformat: option '--extension-sugar': This option has been removed in
7-
version 0.17. Concrete syntax will now always be preserved.
8-
Usage: ocamlformat [OPTION]… [SRC]…
9-
Try 'ocamlformat --help' for more information.
10-
[1]
11-
12-
$ ocamlformat a.ml --let-open preserve
13-
ocamlformat: option '--let-open': This option has been removed in version
14-
0.17. Concrete syntax will now always be preserved.
15-
Usage: ocamlformat [OPTION]… [SRC]…
16-
Try 'ocamlformat --help' for more information.
17-
[1]
18-
19-
$ ocamlformat a.ml --escape-chars preserve
20-
ocamlformat: option '--escape-chars': This option has been removed in version
21-
0.16. Concrete syntax will now always be preserved.
22-
Usage: ocamlformat [OPTION]… [SRC]…
23-
Try 'ocamlformat --help' for more information.
24-
[1]
25-
26-
$ ocamlformat a.ml --escape-strings preserve
27-
ocamlformat: option '--escape-strings': This option has been removed in
28-
version 0.16. Concrete syntax will now always be preserved.
29-
Usage: ocamlformat [OPTION]… [SRC]…
30-
Try 'ocamlformat --help' for more information.
31-
[1]
32-
33-
$ ocamlformat a.ml --doc-comments-val unset
34-
ocamlformat: option '--doc-comments-val': This option has been removed in
35-
version 0.16. If you are using `doc-comments-val=before` in
36-
combination with `doc-comments=before` then only
37-
`doc-comments=before` is now required to achive the same
38-
behavior. If you are using `doc-comments-val=before` in
39-
combination with `doc-comments=after` this behavior is not
40-
available anymore. If you are using `doc-comments-val=after` in
41-
combination with `doc-comments=before` please now use
42-
`doc-comments=before-except-val`. If you are using
43-
`doc-comments-val=after` in combination with
44-
`doc-comments=after` then only
45-
`doc-comments=after-when-possible` is now required to achieve
46-
the same behavior. If you are using `doc-comments-val=unset` the
47-
same behavior can now be achieved by setting `doc-comments`
48-
only.
49-
Usage: ocamlformat [OPTION]… [SRC]…
50-
Try 'ocamlformat --help' for more information.
5+
$ ocamlformat a.ml --extension-sugar preserve 2>/dev/null
516
[1]
527

538
An error is also reported if a removed option is set in an .ocamlformat file:
549

5510
$ echo 'escape-chars = preserve' > .ocamlformat
56-
$ ocamlformat a.ml
57-
ocamlformat: Error while parsing $TESTCASE_ROOT/.ocamlformat:
58-
For option "escape-chars": This option has been removed in version 0.16. Concrete syntax will now always be preserved.
59-
[1]
60-
61-
Setting an option to a deprecated value on the command line should also display an error message:
62-
63-
$ ocamlformat a.ml --break-separators=after-and-docked
64-
ocamlformat: option '--break-separators': value `after-and-docked` has been
65-
removed in version 0.12. One can get a similar behaviour by
66-
setting `break-separators=after`, `space-around-lists=false`,
67-
and `dock-collection-brackets=false`.
68-
Usage: ocamlformat [OPTION]… [SRC]…
69-
Try 'ocamlformat --help' for more information.
70-
[1]
71-
72-
$ ocamlformat a.ml --break-string-literals=wrap
73-
ocamlformat: option '--break-string-literals': value `wrap` has been removed
74-
in version 0.12. It has been replaced by the new default `auto`
75-
value, which breaks lines at newlines and wraps string literals
76-
at the margin.
77-
Usage: ocamlformat [OPTION]… [SRC]…
78-
Try 'ocamlformat --help' for more information.
11+
$ ocamlformat a.ml 2>/dev/null
7912
[1]

test/cli/stdin.t

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22

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

5-
$ ocamlformat -
6-
ocamlformat: Must specify at least one of --name, --impl or --intf when reading from stdin
5+
$ echo 'let x = 1' | ocamlformat - 2>/dev/null
76
[1]
87

9-
$ echo 'let x = 1' | ocamlformat -
10-
ocamlformat: Must specify at least one of --name, --impl or --intf when reading from stdin
11-
[1]
12-
13-
$ ocamlformat --inplace -
14-
ocamlformat: Must specify at least one of --name, --impl or --intf when reading from stdin
8+
$ echo 'let x = 1' | ocamlformat --inplace - 2>/dev/null
159
[1]
1610

1711
Nominal cases:
@@ -29,15 +23,13 @@ The kind of syntax --impl/--intf is inferred from the name:
2923

3024
The syntax cannot be inferred if the extension of the file is unsupported:
3125

32-
$ ocamlformat --name a.cpp -
33-
ocamlformat: Cannot deduce file kind from passed --name. Please specify --impl or --intf
26+
$ ocamlformat --name a.cpp - 2>/dev/null
3427
[1]
3528

3629
Cannot specify files with stdin:
3730

3831
$ echo 'let x = 1' > a.ml
39-
$ ocamlformat a.ml -
40-
ocamlformat: Cannot specify stdin together with other inputs
32+
$ ocamlformat a.ml - 2>/dev/null
4133
[1]
4234

4335
The input is named after the '--name' argument in formatting error messages:

test/passing/gen/dune.inc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4480,24 +4480,6 @@
44804480
(package ocamlformat)
44814481
(action (diff open_types.ml.err open_types.ml.stderr)))
44824482

4483-
(rule
4484-
(deps .ocamlformat)
4485-
(package ocamlformat)
4486-
(action
4487-
(with-stdout-to option.ml.stdout
4488-
(with-stderr-to option.ml.stderr
4489-
(run %{bin:ocamlformat} --name option.ml --margin-check %{dep:../tests/option.ml})))))
4490-
4491-
(rule
4492-
(alias runtest)
4493-
(package ocamlformat)
4494-
(action (diff option.ml.ref option.ml.stdout)))
4495-
4496-
(rule
4497-
(alias runtest)
4498-
(package ocamlformat)
4499-
(action (diff option.ml.err option.ml.stderr)))
4500-
45014483
(rule
45024484
(deps .ocamlformat)
45034485
(package ocamlformat)

test/passing/refs.ahrefs/option.ml.err

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ File "option.ml", line 28, characters 3-14:
2020
28 | [@@ocamlformat "if-then-else=bad"]
2121
^^^^^^^^^^^
2222
Warning 47 [attribute-payload]: illegal payload for attribute 'ocamlformat'.
23-
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical', 'vertical', 'keyword-first' or 'k-r'
23+
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical',
24+
'vertical', 'keyword-first' or 'k-r'
2425

2526
File "option.ml", line 39, characters 14-25:
2627
39 | [@@ocamlformat "if-then-else=bad"]
2728
^^^^^^^^^^^
2829
Warning 47 [attribute-payload]: illegal payload for attribute 'ocamlformat'.
29-
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical', 'vertical', 'keyword-first' or 'k-r'
30+
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical',
31+
'vertical', 'keyword-first' or 'k-r'

test/passing/refs.default/option.ml.err

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ File "option.ml", line 28, characters 3-14:
2020
28 | [@@ocamlformat "if-then-else=bad"]
2121
^^^^^^^^^^^
2222
Warning 47 [attribute-payload]: illegal payload for attribute 'ocamlformat'.
23-
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical', 'vertical', 'keyword-first' or 'k-r'
23+
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical',
24+
'vertical', 'keyword-first' or 'k-r'
2425

2526
File "option.ml", line 39, characters 14-25:
2627
39 | [@@ocamlformat "if-then-else=bad"]
2728
^^^^^^^^^^^
2829
Warning 47 [attribute-payload]: illegal payload for attribute 'ocamlformat'.
29-
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical', 'vertical', 'keyword-first' or 'k-r'
30+
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical',
31+
'vertical', 'keyword-first' or 'k-r'

test/passing/refs.janestreet/option.ml.err

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ File "option.ml", line 28, characters 3-14:
2020
28 | [@@ocamlformat "if-then-else=bad"]
2121
^^^^^^^^^^^
2222
Warning 47 [attribute-payload]: illegal payload for attribute 'ocamlformat'.
23-
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical', 'vertical', 'keyword-first' or 'k-r'
23+
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical',
24+
'vertical', 'keyword-first' or 'k-r'
2425

2526
File "option.ml", line 39, characters 14-25:
2627
39 | [@@ocamlformat "if-then-else=bad"]
2728
^^^^^^^^^^^
2829
Warning 47 [attribute-payload]: illegal payload for attribute 'ocamlformat'.
29-
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical', 'vertical', 'keyword-first' or 'k-r'
30+
For option "if-then-else": invalid value 'bad', expected one of 'compact', 'fit-or-vertical',
31+
'vertical', 'keyword-first' or 'k-r'

0 commit comments

Comments
 (0)