Skip to content

Commit db900cc

Browse files
authored
Merge pull request #202 from oxcaml/add-ignored-flag
Add test for ignored flags
2 parents 3cab6af + 170b3b5 commit db900cc

File tree

3 files changed

+203
-3
lines changed

3 files changed

+203
-3
lines changed

src/kernel/mconfig.ml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ let ocaml_ignored_flags =
464464
"-i";
465465
"-inlining-report";
466466
"-keep-docs";
467-
"-keep-docs";
467+
"-no-keep-docs";
468468
"-keep-locs";
469469
"-linkall";
470470
"-make_runtime";
@@ -490,6 +490,7 @@ let ocaml_ignored_flags =
490490
"-only-erasable-extensions";
491491
"-opaque";
492492
"-output-complete-obj";
493+
"-output-complete-exe";
493494
"-output-obj";
494495
"-p";
495496
"-pack";
@@ -647,7 +648,27 @@ let ocaml_ignored_flags =
647648
"-probes";
648649
"-no-probes";
649650
"-probes-optimized";
650-
"-no-probes-optimized"
651+
"-no-probes-optimized";
652+
"-disable-all-extensions";
653+
"-nocwd";
654+
"-with-runtime";
655+
"-without-runtime";
656+
"-ddebug-uids";
657+
"-ddebug-uid-tables";
658+
"-version";
659+
"--version";
660+
"-vnum";
661+
"-warn-help";
662+
"-help";
663+
"--help";
664+
"-match-context-rows";
665+
"-safer-matching";
666+
"-dno-unique-ids";
667+
"-dunique-ids";
668+
"-dno-locations";
669+
"-dlocations";
670+
"-dcamlprimc";
671+
"-dtimings-precision"
651672
]
652673

653674
let ocaml_ignored_parametrized_flags =
@@ -689,6 +710,7 @@ let ocaml_ignored_parametrized_flags =
689710
(* flambda-backend specific *)
690711
"-extension";
691712
"-extension-universe";
713+
"-no-extension";
692714
"-drawfexpr-to";
693715
"-dfexpr-to";
694716
"-dflexpect-to";
@@ -738,7 +760,11 @@ let ocaml_ignored_parametrized_flags =
738760
"-gdwarf-config-shape-reduce-fuel";
739761
"-gdwarf-fidelity";
740762
"-llvm-path";
741-
"-afl-inst-ratio"
763+
"-afl-inst-ratio";
764+
"-config-var";
765+
"-stop-after";
766+
"-plugin";
767+
"-dump-into-file"
742768
]
743769

744770
let ocaml_warnings_spec ~error =

tests/test-dirs/dune

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
(<> %{ocaml_version} 4.12.0+multicore)
1616
(<> %{ocaml_version} 4.12.0+domains))))
1717

18+
(cram
19+
(deps ../../src/kernel/mconfig.ml)
20+
(applies_to ocaml-flags))
21+
1822
; FIXME: re-enable once ppxlib for 5.1 is released
1923
(cram
2024
(applies_to with-ppx)

tests/test-dirs/ocaml-flags.t

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
Get a list of all flags that ocamlopt.opt understands.
2+
$ OCAMLOPT="$MERLIN_TEST_OCAML_PATH/bin/ocamlc"
3+
$ OCAML_FLAGS=$("$OCAMLOPT" --help | grep -oP '(?<= )-[a-z\-_0-9]+(?= )')
4+
5+
Verify that each flag appears in mconfig.ml. Each flag should either be handled or be in
6+
the list of ignored flags. If a new flag appears in this list, you should either make
7+
Merlin handle it or add it to the list of ignored flags.
8+
9+
$ is_intentionally_unhandled () {
10+
> # These flags are unhandled by Merlin and we really do want to raise an error if
11+
> # they are passed.
12+
> case "$1" in
13+
> "-args" | "-args0" | "-depend")
14+
> return 0
15+
> ;;
16+
> *)
17+
> return 1
18+
> ;;
19+
> esac
20+
> }
21+
22+
$ mconfig="../../src/kernel/mconfig.ml"
23+
$ echo "$OCAML_FLAGS" | while IFS= read -r flag; do
24+
> grep -q "\"$flag\"" "$mconfig" || \
25+
> is_intentionally_unhandled "$flag" || \
26+
> echo "Unhandled flag: $flag"
27+
> done
28+
29+
This list is printed to ensure that a change to the help text does not break the parsing
30+
logic.
31+
$ echo "$OCAML_FLAGS"
32+
-a
33+
-alert
34+
-absname
35+
-no-absname
36+
-annot
37+
-as-argument-for
38+
-as-parameter
39+
-bin-annot
40+
-bin-annot-cms
41+
-bin-annot-occurrences
42+
-c
43+
-cc
44+
-cclib
45+
-ccopt
46+
-cmi-file
47+
-color
48+
-error-style
49+
-compat-32
50+
-config
51+
-config-var
52+
-custom
53+
-disable-all-extensions
54+
-only-erasable-extensions
55+
-dllib
56+
-dllpath
57+
-dtypes
58+
-extension
59+
-no-extension
60+
-extension-universe
61+
-for-pack
62+
-g
63+
-no-g
64+
-stop-after
65+
-i
66+
-impl
67+
-instantiate
68+
-intf
69+
-intf-suffix
70+
-intf_suffix
71+
-keep-docs
72+
-no-keep-docs
73+
-keep-locs
74+
-no-keep-locs
75+
-labels
76+
-linkall
77+
-llvm-backend
78+
-make-runtime
79+
-make_runtime
80+
-modern
81+
-alias-deps
82+
-no-alias-deps
83+
-app-funct
84+
-no-app-funct
85+
-directory
86+
-no-check-prims
87+
-noassert
88+
-noautolink
89+
-nolabels
90+
-nostdlib
91+
-no-auto-include-otherlibs
92+
-nocwd
93+
-nopervasives
94+
-o
95+
-opaque
96+
-open
97+
-output-obj
98+
-output-complete-obj
99+
-output-complete-exe
100+
-pack
101+
-parameter
102+
-pp
103+
-ppx
104+
-plugin
105+
-principal
106+
-no-principal
107+
-rectypes
108+
-no-rectypes
109+
-runtime-variant
110+
-with-runtime
111+
-without-runtime
112+
-safe-string
113+
-safer-matching
114+
-short-paths
115+
-strict-sequence
116+
-no-strict-sequence
117+
-strict-formats
118+
-no-strict-formats
119+
-thread
120+
-unboxed-types
121+
-no-unboxed-types
122+
-ddebug-uids
123+
-ddebug-uid-tables
124+
-unsafe
125+
-use-runtime
126+
-use_runtime
127+
-v
128+
-verbose
129+
-verbose-types
130+
-no-verbose-types
131+
-version
132+
--version
133+
-vmthread
134+
-vnum
135+
-w
136+
-warn-error
137+
-warn-help
138+
-where
139+
-match-context-rows
140+
-use-prims
141+
-shape-format
142+
-dno-unique-ids
143+
-dunique-ids
144+
-dno-locations
145+
-dlocations
146+
-dsource
147+
-dparsetree
148+
-dtypedtree
149+
-dshape
150+
-drawlambda
151+
-dslambda
152+
-dlambda
153+
-dblambda
154+
-dletreclambda
155+
-dinstr
156+
-dcamlprimc
157+
-dtimings
158+
-dtimings-precision
159+
-dcounters
160+
-dprofile
161+
-dgranularity
162+
-dump-into-file
163+
-dump-into-csv
164+
-dump-dir
165+
-debug-ocaml
166+
-args
167+
-args0
168+
-depend
169+
-help
170+
--help

0 commit comments

Comments
 (0)