merlin
merlin copied to clipboard
Test fails with custom opam root
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.
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 :)
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.
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'
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
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?