Skip to content

Commit

Permalink
test: opam constraint generation
Browse files Browse the repository at this point in the history
This generalizes the test for ocaml#3431 and actually reveals that nested ors
are incorrectly translated at the moment: in `p_or3`, `(or :a :b :c)`
gets converted to `{a | b & c}`.

It also adds a test for `(and)` and `(or)` with no argument, which
should fail cleanly.

Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed May 15, 2023
1 parent 60f4038 commit 11129a7
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 26 deletions.
26 changes: 0 additions & 26 deletions test/blackbox-tests/test-cases/github3431.t

This file was deleted.

95 changes: 95 additions & 0 deletions test/blackbox-tests/test-cases/opam-constraints.t
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 11129a7

Please sign in to comment.