Skip to content

Commit

Permalink
better tests
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Chávarri <[email protected]>
  • Loading branch information
jchavarri committed Mar 28, 2024
1 parent 31312fa commit 2b74737
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions test/blackbox-tests/test-cases/merlin/get-set-contexts.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,58 @@ Showcase behavior of the GetContexts ocaml-merlin command

Showcase behavior of the SetContext ocaml-merlin command

$ FILE=$PWD/lib3.ml
$ printf '(4:File%d:%s)(10:SetContext3:alt)(4:File%d:%s)(4:File%d:%s)' ${#FILE} $FILE | dune ocaml-merlin
((5:ERROR59:No config found for file lib3.ml. Try calling 'dune build'.))((5:ERROR53:No config found for file .. Try calling 'dune build'.))((5:ERROR53:No config found for file .. Try calling 'dune build'.))
$ lib1=foo
$ lib2=bar
$ cat >dune <<EOF
> (library
> (name $lib1)
> (modules $lib1)
> (enabled_if (= %{context_name} "default")))
> (library
> (name $lib2)
> (modules $lib2)
> (enabled_if (= %{context_name} "alt")))
> EOF

$ touch $lib1.ml $lib2.ml

$ dune build

$ FILE1=$PWD/$lib1.ml
$ FILE2=$PWD/$lib2.ml

Request config for file in alt context before calling SetContext

$ printf '(4:File%d:%s)' ${#FILE2} $FILE2 | dune ocaml-merlin | dune format-dune-file
((5:ERROR58:No config found for file bar.ml. Try calling 'dune build'.))

Request config for file in alt context after calling SetContext

$ printf '(10:SetContext3:alt)(4:File%d:%s)' ${#FILE2} $FILE2 | dune ocaml-merlin | dune format-dune-file
((5:ERROR58:No config found for file bar.ml. Try calling 'dune build'.))

Request config for file in default context before and after calling SetContext

$ printf '(4:File%d:%s)(10:SetContext3:alt)(4:File%d:%s)' ${#FILE1} $FILE1 ${#FILE1} $FILE1 | dune ocaml-merlin | dune format-dune-file
((6:STDLIB34:/home/me/code/dune/_opam/lib/ocaml)
(17:EXCLUDE_QUERY_DIR)
(1:B143:$TESTCASE_ROOT/_build/default/.foo.objs/byte)
(1:S113:$TESTCASE_ROOT)
(3:FLG
(2:-w51:@1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-4016:-strict-sequence15:-strict-formats12:-short-paths10:-keep-locs2:-g)))

((5:ERROR58:No config found for file foo.ml. Try calling 'dune build'.))

Combine all

$ printf '(4:File%d:%s)(10:SetContext3:alt)(4:File%d:%s)(4:File%d:%s)' ${#FILE1} $FILE1 ${#FILE1} $FILE1 ${#FILE2} $FILE2 | dune ocaml-merlin | dune format-dune-file
((6:STDLIB34:/home/me/code/dune/_opam/lib/ocaml)
(17:EXCLUDE_QUERY_DIR)
(1:B143:$TESTCASE_ROOT/_build/default/.foo.objs/byte)
(1:S113:$TESTCASE_ROOT)
(3:FLG
(2:-w51:@1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-4016:-strict-sequence15:-strict-formats12:-short-paths10:-keep-locs2:-g)))

((5:ERROR58:No config found for file foo.ml. Try calling 'dune build'.))

((5:ERROR58:No config found for file bar.ml. Try calling 'dune build'.))

0 comments on commit 2b74737

Please sign in to comment.