ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.57k stars 233 forks source link

Test fails with custom opam root #1105

Open lpw25 opened 4 years ago

lpw25 commented 4 years ago

When I run dune build @runtest I always get:

---tests/test-dirs/locate/context-detection/mod_constr.t
+++tests/test-dirs/locate/context-detection/mod_constr.t.corrected
File "tests/test-dirs/locate/context-detection/mod_constr.t", line 6, characters 0-1:

    $ $MERLIN single locate -look-for ml -position 2:13 -filename ./mod_constr.ml < ./mod_constr.ml
    {
      "class": "return",
      "value": {
-|      "file": "~opam/lib/ocaml/string.ml",
+|      "file": "/usr/local/home/lwhite/opam-root/4.09.0/lib/ocaml/string.ml",
        "pos": {
          "line": 1,
          "col": 0
        }
      },
      "notifications": []
    }

which is a bit annoying because then if I run promote for other tests I have to manually undo the promotion of this test.

trefis commented 4 years ago

If you have a better sed line to offer, I'll take it. Notice that it already special cased one particular custom root, but I don't think the approach is scalable.

Otherwise, I suggest you symlink .opam to your custom opam-root :)

lpw25 commented 4 years ago

What about using this jq:

jq 'walk(if type == "object" and has("file") then (.file |= match("([A-Za-z.]+)$").string) else . end)'

It should replace all file paths with just their basename.

olafhering commented 3 years ago

What is the expected outcome anyway? For me it fails like this:

[  129s] $ (cd _build/.sandbox/f948a16328af0270471659460c901e07/default && /usr/bin/diff -u tests/test-dirs/locate/context-detection/cd-mod_constr.t/run.t tests/test-dirs/locate/context-detection/cd-mod_constr.t/run.t.corrected)
[  129s] --- tests/test-dirs/locate/context-detection/cd-mod_constr.t/run.t 2021-04-14 12:16:29.943666650 +0000
[  129s] +++ tests/test-dirs/locate/context-detection/cd-mod_constr.t/run.t.corrected   2021-04-14 12:17:09.499666997 +0000
[  129s] @@ -3,7 +3,7 @@
[  129s]    {
[  129s]      "class": "return",
[  129s]      "value": {
[  129s] -      "file": "lib/ocaml/string.ml",
[  129s] +      "file": "/usr/lib64/ocaml/string.mli",
[  129s]        "pos": {
[  129s]          "line": 1,
[  129s]          "col": 0
[  129s] + echo 'dune runtest failed'
olafhering commented 3 years ago

Well, I added this change to ocaml-merlin.spec to fix build.

 %check
+sed -i~ '
+s@"lib/ocaml/string.ml"@"%{ocaml_standard_library}/string.mli"@
+'  tests/test-dirs/locate/context-detection/cd-mod_constr.t/run.t
+diff -u "$_"~ "$_" && exit 1
 %ocaml_dune_test
olafhering commented 3 years ago

The change above fails when applied on a 32bit host, such as i586/armv7l/armv6l. Not sure why the testcase makes a difference between 64bit and 32bit builds.

The question above still stands: what is the expected outcome?