l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
361 stars 29 forks source link

Update YAML library #109

Closed l3nz closed 2 years ago

l3nz commented 4 years ago

version

0.4.0 , JVM

problem

Updating to 1.0.10 breaks YAML tests.

repro

If we set:

[io.forward/yaml "1.0.9" :scope "provided"]

then test break, as in:

FAIL in (test-yaml) (presets_test.cljc:367)
YAML single value
expected: (= (parse-cmds-simpler ["foo" "--val" "a: 1\nb: 2"] (mkDummyCfg {:option "val", :as "x", :type :yaml})) {:commandline {:_arguments [], :val {"a" 1, "b" 2}}, :error-text "", :parse-errors :NONE})
  actual: (not (= {:commandline {}, :parse-errors :ERR-PARMS-SUBCMD, :error-text "Error while parsing option \"--val a: 1\\nb: 2\": java.lang.AssertionError: Assert failed: with-yaml?"} {:commandline {:_arguments [], :val {"a" 1, "b" 2}}, :error-text "", :parse-errors :NONE}))

lein test :only cli-matic.presets-test/test-yaml

FAIL in (test-yaml) (presets_test.cljc:381)
Slurping multiline YAML
expected: (= (parse-cmds-simpler ["foo" "--val" "resources/yaml_simple.yaml"] (mkDummyCfg {:option "val", :as "x", :type :yamlfile})) {:commandline {:_arguments [], :val {"list" [1 2 "hi"], "intval" 100, "strval" "good"}}, :error-text "", :parse-errors :NONE})
  actual: (not (= {:commandline {}, :parse-errors :ERR-PARMS-SUBCMD, :error-text "Error while parsing option \"--val resources/yaml_simple.yaml\": java.lang.AssertionError: Assert failed: with-yaml?"} {:commandline {:_arguments [], :val {"list" [1 2 "hi"], "intval" 100, "strval" "good"}}, :error-text "", :parse-errors :NONE}))

lein test :only cli-matic.presets-test/test-yaml

FAIL in (test-yaml) (presets_test.cljc:396)
Complex multiline YAML
expected: (= (-> (parse-cmds-simpler ["foo" "--val" "resources/yaml_full.yaml"] (mkDummyCfg {:option "val", :as "x", :type :yamlfile})) (get-in [:commandline :val]) (select-keys ["invoice" "date"])) {"invoice" 34843, "date" #inst "2001-01-23T00:00:00.000-00:00"})
  actual: (not (= {} {"invoice" 34843, "date" #inst "2001-01-23T00:00:00.000-00:00"}))

Of course we would like to detect EITHER versions.

diavoletto76 commented 3 years ago

Hi, the issue seems to be caused by the fact that io.forward/yaml 1.0.10 was compiled with Java 11: binaries uploaded to Clojars are incompatible with Java 8. I tried to compile/install version 1.0.10 with Java 8: it works fine and even tests in presets_test.cljc run smoothly.

I don't know how do you expect to fix this issue. Maybe we can stick with yaml 1.0.9 waiting for the author to release compatible binaries.

l3nz commented 2 years ago

As @borkdude says it would be better to switch to [clj-commons/clj-yaml "0.7.0"] - see https://github.com/l3nz/cli-matic/issues/113#issuecomment-1044668837

Worth trying, as next up will be a major release: https://github.com/clj-commons/clj-yaml

borkdude commented 2 years ago

@l3nz Are you saying you are waiting for a major release of clj-yaml? Or do you mean something different?

l3nz commented 2 years ago

@borkdude No I meant this will be a significant change so an incompatible library is kind-of OK