diff --git a/test/blackbox-tests/test-cases/github3431.t b/test/blackbox-tests/test-cases/github3431.t deleted file mode 100644 index 5bc8ac8334b..00000000000 --- a/test/blackbox-tests/test-cases/github3431.t +++ /dev/null @@ -1,26 +0,0 @@ -When we generate an opam formula that would require parentheses, they are -not present. -This is actually a bug in opam-file-format: ocaml/opam-file-format/issues#56. -See #3431. - - $ cat > dune-project << EOF - > (lang dune 3.7) - > - > (generate_opam_files) - > - > (package - > (name p) - > (allow_empty) - > (depends - > (a - > (and - > (or :with-test :dev) - > (>= 1.1.0))))) - > EOF - - $ dune build - - $ grep '"a"' p.opam - "a" {with-test | dev & >= "1.1.0"} - -(the correct line is: "a" {(with-test | dev) & >= "1.1.0"}) diff --git a/test/blackbox-tests/test-cases/opam-constraints.t b/test/blackbox-tests/test-cases/opam-constraints.t new file mode 100644 index 00000000000..dea5da22221 --- /dev/null +++ b/test/blackbox-tests/test-cases/opam-constraints.t @@ -0,0 +1,95 @@ +This tests the dune-project -> opam file generation with different kinds of +constraints. + + $ cat > dune-project << EOF + > (lang dune 2.1) + > (generate_opam_files) + > (package + > (name p) + > (depends + > ; unary ops + > (p_eq (= v)) + > (p_lt (< v)) + > (p_gt (> v)) + > (p_ge (>= v)) + > (p_le (<= v)) + > (p_ne (<> v)) + > ; binary ops + > (p_bin (<> :os win32)) + > ; and + > (p_and2 (and :a :b)) + > (p_and1 (and :a)) + > (p_and3 (and :a :b :c)) + > ; or + > (p_or2 (or :a :b)) + > (p_or1 (or :a)) + > (p_or3 (or :a :b :c)) ; buggy output + > ; mixed operations + > (p_and_in_or (or :a (and :b :c))) ; buggy output, see #3431 + > (p_or_in_and (and :a (or :b :c))) + > )) + > EOF + + $ dune build + + $ cat p.opam + # This file is generated by dune, edit dune-project instead + opam-version: "2.0" + depends: [ + "dune" {>= "2.1"} + "p_eq" {= "v"} + "p_lt" {< "v"} + "p_gt" {> "v"} + "p_ge" {>= "v"} + "p_le" {<= "v"} + "p_ne" {!= "v"} + "p_bin" {os != "win32"} + "p_and2" {a & b} + "p_and1" {a} + "p_and3" {a & b & c} + "p_or2" {a | b} + "p_or1" {a} + "p_or3" {a | b & c} + "p_and_in_or" {a | b & c} + "p_or_in_and" {a & b | c} + ] + build: [ + ["dune" "subst"] {pinned} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ] + +`(and)`/`(or)` with no argument should get rejected. + + $ cat > dune-project << EOF + > (lang dune 2.1) + > (generate_opam_files) + > (package + > (name p) + > (depends + > (p (and)))) + > EOF + + $ dune build 2>&1 | grep 'Internal error' + Internal error, please report upstream including the contents of _build/log. + + $ cat > dune-project << EOF + > (lang dune 2.1) + > (generate_opam_files) + > (package + > (name p) + > (depends + > (p (or)))) + > EOF + + $ dune build 2>&1 | grep 'Internal error' + Internal error, please report upstream including the contents of _build/log.