This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
(cram
|
||||
(deps opam-vars)
|
||||
(applies_to opam-var-os))
|
||||
|
||||
(data_only_dirs fake_opam_root)
|
||||
|
||||
; Without this, no copying rules will be setup for the .opam-switch directory
|
||||
|
||||
(subdir
|
||||
fake_opam_root/default
|
||||
(dirs :standard .opam-switch))
|
||||
|
||||
; We trick opam into thinking it has a config file with fake_opam_root so that we can
|
||||
; access the os variables without having to do opam init
|
||||
|
||||
(rule
|
||||
(target opam-vars)
|
||||
(deps
|
||||
(source_tree fake_opam_root))
|
||||
(action
|
||||
(with-stdout-to
|
||||
%{target}
|
||||
(progn
|
||||
(run %{bin:opam} --cli 2.1 var --root fake_opam_root arch)
|
||||
(run %{bin:opam} --cli 2.1 var --root fake_opam_root os)
|
||||
(run %{bin:opam} --cli 2.1 var --root fake_opam_root os-distribution)
|
||||
(run %{bin:opam} --cli 2.1 var --root fake_opam_root os-family)
|
||||
(run %{bin:opam} --cli 2.1 var --root fake_opam_root os-version)))))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
opam-version: "2.0"
|
||||
switch: "default"
|
||||
installed-switches: ["default"]
|
||||
|
|
@ -0,0 +1 @@
|
|||
opam-version: "2.0"
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
$ . ../helpers.sh
|
||||
|
||||
If both make and gmake are available, we should prefer make.
|
||||
|
||||
opam doesn't resolve make but rather runs make literally so it is up to whatever is in
|
||||
PATH to resolve it. This does mean that make is preferred over gmake so we should
|
||||
replicate that behaviour.
|
||||
|
||||
We create a dummy package that will output the value of the opam make variable:
|
||||
$ mkrepo
|
||||
> mkpkg testpkg << EOF
|
||||
> build: [ "echo" make ]
|
||||
> EOF
|
||||
> solve testpkg 2> /dev/null
|
||||
|
||||
We now create dummy versions of make and gmake.
|
||||
$ cat > make; cat > gmake
|
||||
We add the current directory to PATH. Dune will expand %{make} and should prefer make over
|
||||
gmake.
|
||||
$ PATH=.:$PATH
|
||||
> build_pkg testpkg
|
||||
$TESTCASE_ROOT/gmake
|
||||
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
Demonstrate how dependencies are filtered in opam files:
|
||||
|
||||
$ . ../helpers.sh
|
||||
|
||||
$ build_single_package() {
|
||||
> solve_project <<EOF
|
||||
> (lang dune 3.11)
|
||||
> (package
|
||||
> (name x)
|
||||
> (depends
|
||||
> $1))
|
||||
> EOF
|
||||
> build_pkg $1
|
||||
> }
|
||||
|
||||
$ mkrepo
|
||||
|
||||
$ mkpkg "foo"
|
||||
|
||||
Regular dependencies
|
||||
|
||||
$ mkpkg "testpkg" 1 <<'EOF'
|
||||
> depends: [ "foo" {version = 1} ]
|
||||
> EOF
|
||||
|
||||
$ solve testpkg
|
||||
Solution for dune.lock:
|
||||
- foo.0.0.1
|
||||
- testpkg.1
|
||||
|
||||
$ mkpkg "testpkg" 2 <<'EOF'
|
||||
> depends: [ "foo" {version = 1} ]
|
||||
> EOF
|
||||
|
||||
$ solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.2
|
||||
|
||||
Depopts. We don't have proper support for depopts yet, so these don't work.
|
||||
When depopts are enabled though, the test should demonstrate that depopts works
|
||||
the same way as depends
|
||||
|
||||
$ mkpkg "testpkg" 1 <<'EOF'
|
||||
> depopts: [ "foo" {version = 1} ]
|
||||
> EOF
|
||||
|
||||
$ solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.2
|
||||
|
||||
$ mkpkg "testpkg" 2 <<'EOF'
|
||||
> depopts: [ "foo" {version = 1} ]
|
||||
> EOF
|
||||
|
||||
$ solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.2
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
$ . ../helpers.sh
|
||||
|
||||
Here we test the translation and implementation of global opam variables. OS specific
|
||||
variables can be found in `opam-var-os.t`.
|
||||
|
||||
$ mkrepo
|
||||
> mkpkg testpkg << EOF
|
||||
> build: [
|
||||
> [ "echo" jobs ]
|
||||
> [ "echo" make ]
|
||||
> [ "echo" user ]
|
||||
> [ "echo" group ]
|
||||
> ]
|
||||
> EOF
|
||||
> solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.0.0.1
|
||||
$ cat dune.lock/testpkg.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
(build
|
||||
(progn
|
||||
(run echo %{jobs})
|
||||
(run echo %{make})
|
||||
(run echo %{user})
|
||||
(run echo %{group})))
|
||||
|
||||
|
||||
- The implementation of %{user} uses Unix.getlogin which doesn't work in our Linux CI job.
|
||||
- The implementation of %{make} prefers gmake over make and is tested in `make.t`.
|
||||
|
||||
Therefore we modify the lockfile here to remove these from the opam file:
|
||||
|
||||
$ mkpkg testpkg << EOF
|
||||
> build: [
|
||||
> [ "echo" jobs ]
|
||||
> [ "echo" group ]
|
||||
> ]
|
||||
> EOF
|
||||
> solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.0.0.1
|
||||
The value for "jobs" should always be 1.
|
||||
|
||||
$ GROUP="$(id -gn)"
|
||||
> build_pkg testpkg 2>&1 | sed "s/$GROUP/GROUP/g"
|
||||
1
|
||||
GROUP
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
$ . ../helpers.sh
|
||||
|
||||
Here we test global opam variables that are system specific. Since these values change
|
||||
between systems, we can't hardcode them in the test. Instead, we use the opam var command
|
||||
to compare their values.
|
||||
|
||||
# arch os os-distribution os-family os-version user group
|
||||
|
||||
These variables are usually set to keep tests consistent across different
|
||||
platforms but for this test we need to expose the real platform to dune, so
|
||||
unset them all.
|
||||
$ unset DUNE_CONFIG__OS DUNE_CONFIG__ARCH DUNE_CONFIG__OS_FAMILY DUNE_CONFIG__OS_DISTRIBUTION DUNE_CONFIG__OS_VERSION DUNE_CONFIG__SYS_OCAML_VERSION
|
||||
|
||||
$ mkrepo
|
||||
> mkpkg testpkg <<EOF
|
||||
> build: [
|
||||
> ["echo" arch]
|
||||
> ["echo" os]
|
||||
> ["echo" os-distribution]
|
||||
> ["echo" os-family]
|
||||
> ["echo" os-version]
|
||||
> ]
|
||||
> EOF
|
||||
> solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.0.0.1
|
||||
$ cat dune.lock/testpkg.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
(build
|
||||
(progn
|
||||
(run echo %{arch})
|
||||
(run echo %{os})
|
||||
(run echo %{os_distribution})
|
||||
(run echo %{os_family})
|
||||
(run echo %{os_version})))
|
||||
|
||||
We write all the dune values to a file and then diff them with the output of opam var.
|
||||
|
||||
$ build_pkg testpkg 2> dune-vars
|
||||
|
||||
The two files should be identical.
|
||||
|
||||
$ diff --label="opam-vars" opam-vars --label="dune-vars" dune-vars
|
||||
|
||||
Getting the sys-ocaml-version variable consistent is rather annoying because it
|
||||
depends on whether we have a system installed OCaml. So we just test it
|
||||
separately here:
|
||||
|
||||
$ mkpkg testpkg <<EOF
|
||||
> build: [
|
||||
> ["echo" sys-ocaml-version]
|
||||
> ]
|
||||
> EOF
|
||||
> solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.0.0.1
|
||||
|
||||
$ ocaml_version="$(ocaml -vnum)"
|
||||
$ build_pkg testpkg 2>&1 | sed "s/$ocaml_version/OCAML_VERSION/g"
|
||||
OCAML_VERSION
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
$ . ../helpers.sh
|
||||
|
||||
Here we test the translation and implementation of opam package variables.
|
||||
|
||||
We echo each package variable.
|
||||
|
||||
$ mkrepo
|
||||
> mkpkg "testpkg" <<'EOF'
|
||||
> depends: [ "foo" ]
|
||||
> build: [
|
||||
> [ "echo" "1" name ]
|
||||
> [ "echo" "2" _:name ]
|
||||
> [ "echo" "3" foo:name ]
|
||||
> [ "echo" "4" version ]
|
||||
> [ "echo" "5" _:version ]
|
||||
> [ "echo" "6" foo:version ]
|
||||
> [ "echo" "9" _:installed ]
|
||||
> [ "echo" "10" foo:installed ]
|
||||
> [ "echo" "11" _:enable ]
|
||||
> [ "echo" "12" foo:enable ]
|
||||
> [ "echo" "13" _:pinned ]
|
||||
> [ "echo" "14" foo:pinned ]
|
||||
> [ "echo" "15" _:bin ]
|
||||
> [ "echo" "16" foo:bin ]
|
||||
> [ "echo" "17" _:sbin ]
|
||||
> [ "echo" "18" foo:sbin ]
|
||||
> [ "echo" "19" _:lib ]
|
||||
> [ "echo" "20" foo:lib ]
|
||||
> [ "echo" "21" _:man ]
|
||||
> [ "echo" "22" foo:man ]
|
||||
> [ "echo" "23" _:doc ]
|
||||
> [ "echo" "24" foo:doc ]
|
||||
> [ "echo" "25" _:share ]
|
||||
> [ "echo" "26" foo:share ]
|
||||
> [ "echo" "27" _:etc ]
|
||||
> [ "echo" "28" foo:etc ]
|
||||
> [ "echo" "31" _:dev ]
|
||||
> [ "echo" "32" foo:dev ]
|
||||
> [ "echo" "35" with-test ]
|
||||
> [ "echo" "36" _:with-test ]
|
||||
> [ "echo" "37" foo:with-test ]
|
||||
> [ "echo" "38" with-doc ]
|
||||
> [ "echo" "39" _:with-doc ]
|
||||
> [ "echo" "40" foo:with-doc ]
|
||||
> [ "echo" "41" _:with-dev-setup ]
|
||||
> [ "echo" "42" foo:with-dev-setup ]
|
||||
> ]
|
||||
> EOF
|
||||
> mkpkg "foo" <<EOF
|
||||
> EOF
|
||||
> solve testpkg
|
||||
Solution for dune.lock:
|
||||
- foo.0.0.1
|
||||
- testpkg.0.0.1
|
||||
Inspecting the lockfile we can see how each opam package variable was translated into a
|
||||
corresponding Dune version.
|
||||
|
||||
$ cat dune.lock/testpkg.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
(build
|
||||
(progn
|
||||
(run echo 1 %{pkg-self:name})
|
||||
(run echo 2 %{pkg-self:name})
|
||||
(run echo 3 %{pkg:foo:name})
|
||||
(run echo 4 %{pkg-self:version})
|
||||
(run echo 5 %{pkg-self:version})
|
||||
(run echo 6 %{pkg:foo:version})
|
||||
(run echo 9 %{pkg-self:installed})
|
||||
(run echo 10 %{pkg:foo:installed})
|
||||
(run
|
||||
echo
|
||||
11
|
||||
(if
|
||||
(catch_undefined_var %{pkg-self:installed} false)
|
||||
enable
|
||||
disable))
|
||||
(run
|
||||
echo
|
||||
12
|
||||
(if
|
||||
(catch_undefined_var %{pkg:foo:installed} false)
|
||||
enable
|
||||
disable))
|
||||
(run echo 13 %{pkg-self:pinned})
|
||||
(run echo 14 %{pkg:foo:pinned})
|
||||
(run echo 15 %{pkg-self:bin})
|
||||
(run echo 16 %{pkg:foo:bin})
|
||||
(run echo 17 %{pkg-self:sbin})
|
||||
(run echo 18 %{pkg:foo:sbin})
|
||||
(run echo 19 %{pkg-self:lib})
|
||||
(run echo 20 %{pkg:foo:lib})
|
||||
(run echo 21 %{pkg-self:man})
|
||||
(run echo 22 %{pkg:foo:man})
|
||||
(run echo 23 %{pkg-self:doc})
|
||||
(run echo 24 %{pkg:foo:doc})
|
||||
(run echo 25 %{pkg-self:share})
|
||||
(run echo 26 %{pkg:foo:share})
|
||||
(run echo 27 %{pkg-self:etc})
|
||||
(run echo 28 %{pkg:foo:etc})
|
||||
(run echo 31 %{pkg-self:dev})
|
||||
(run echo 32 %{pkg:foo:dev})
|
||||
(run echo 35 %{pkg-self:with-test})
|
||||
(run echo 36 %{pkg-self:with-test})
|
||||
(run echo 37 %{pkg:foo:with-test})
|
||||
(run echo 38 %{pkg-self:with-doc})
|
||||
(run echo 39 %{pkg-self:with-doc})
|
||||
(run echo 40 %{pkg:foo:with-doc})
|
||||
(run echo 41 %{pkg-self:with-dev-setup})
|
||||
(run echo 42 %{pkg:foo:with-dev-setup})))
|
||||
|
||||
(depends foo)
|
||||
|
||||
The values here are not important, but Dune should be able to interpret the variables.
|
||||
|
||||
$ build_pkg testpkg
|
||||
File "dune.lock/testpkg.pkg", line 45, characters 15-36:
|
||||
45 | (run echo 35 %{pkg-self:with-test})
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-test"
|
||||
File "dune.lock/testpkg.pkg", line 46, characters 15-36:
|
||||
46 | (run echo 36 %{pkg-self:with-test})
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-test"
|
||||
File "dune.lock/testpkg.pkg", line 47, characters 15-35:
|
||||
47 | (run echo 37 %{pkg:foo:with-test})
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-test"
|
||||
File "dune.lock/testpkg.pkg", line 48, characters 15-35:
|
||||
48 | (run echo 38 %{pkg-self:with-doc})
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-doc"
|
||||
File "dune.lock/testpkg.pkg", line 49, characters 15-35:
|
||||
49 | (run echo 39 %{pkg-self:with-doc})
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-doc"
|
||||
File "dune.lock/testpkg.pkg", line 50, characters 15-34:
|
||||
50 | (run echo 40 %{pkg:foo:with-doc})
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-doc"
|
||||
File "dune.lock/testpkg.pkg", line 51, characters 15-41:
|
||||
51 | (run echo 41 %{pkg-self:with-dev-setup})
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-dev-setup"
|
||||
File "dune.lock/testpkg.pkg", line 52, characters 15-40:
|
||||
52 | (run echo 42 %{pkg:foo:with-dev-setup})))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: Undefined package variable "with-dev-setup"
|
||||
[1]
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
$ . ../helpers.sh
|
||||
|
||||
These opam variables are known as "switch variables" in opam, but since in Dune we don't
|
||||
have switches, we consider them glboal variables. To keep inline with opam we consider
|
||||
there to be a single switch named "dune" and all the installation locations should be in
|
||||
the package building directories.
|
||||
|
||||
Note that misc is not supported in dune and a test for it can be found in
|
||||
opam-var-unsupported.t
|
||||
$ mkrepo
|
||||
$ mkpkg testpkg <<EOF
|
||||
> build: [
|
||||
> [ "echo" switch ]
|
||||
> [ "echo" build ]
|
||||
> [ "echo" prefix ]
|
||||
> [ "echo" lib ]
|
||||
> [ "echo" libexec ]
|
||||
> [ "echo" bin ]
|
||||
> [ "echo" sbin ]
|
||||
> [ "echo" share ]
|
||||
> [ "echo" doc ]
|
||||
> [ "echo" etc ]
|
||||
> [ "echo" man ]
|
||||
> [ "echo" toplevel ]
|
||||
> [ "echo" stublibs ]
|
||||
> ]
|
||||
> EOF
|
||||
> solve testpkg
|
||||
Solution for dune.lock:
|
||||
- testpkg.0.0.1
|
||||
$ cat dune.lock/testpkg.pkg
|
||||
(version 0.0.1)
|
||||
|
||||
(build
|
||||
(progn
|
||||
(run echo %{switch})
|
||||
(run echo %{build})
|
||||
(run echo %{prefix})
|
||||
(run echo %{lib})
|
||||
(run echo %{libexec})
|
||||
(run echo %{bin})
|
||||
(run echo %{sbin})
|
||||
(run echo %{share})
|
||||
(run echo %{doc})
|
||||
(run echo %{etc})
|
||||
(run echo %{man})
|
||||
(run echo %{toplevel})
|
||||
(run echo %{stublibs})))
|
||||
|
||||
$ build_pkg testpkg 2>&1 | sed -E 's#.*.sandbox/[^/]+#.sandbox/$SANDBOX#g'
|
||||
dune
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/source
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/lib
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/lib
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/bin
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/sbin
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/share
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/doc
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/etc
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/man
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/lib/toplevel
|
||||
.sandbox/$SANDBOX/_private/default/.pkg/testpkg/target/lib/stublibs
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
$ . ../helpers.sh
|
||||
|
||||
$ mkrepo
|
||||
> fail_solve() {
|
||||
> mkpkg testpkg <<EOF
|
||||
> build: [ "echo" $1 ]
|
||||
> EOF
|
||||
> solve_output=$(solve testpkg 2>&1)
|
||||
> if [ $? -eq 0 ]; then
|
||||
> echo "Expected solve to fail, but it succeeded" >&2
|
||||
> else
|
||||
> echo "$solve_output" >&2
|
||||
> fi
|
||||
> }
|
||||
|
||||
opam variables that are explicitly unsupported in dune
|
||||
|
||||
These should all have nice error messages explaining that they are not supported.
|
||||
|
||||
# opam-version
|
||||
$ fail_solve opam-version
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "opam-version" is not supported.
|
||||
# root
|
||||
$ fail_solve root
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "root" is not supported.
|
||||
# _:hash
|
||||
$ fail_solve _:hash
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "hash" is not supported.
|
||||
# _:build-id
|
||||
$ fail_solve _:build-id
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "build-id" is not supported.
|
||||
# misc
|
||||
$ fail_solve misc
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "misc" is not supported.
|
||||
# _:misc
|
||||
$ fail_solve _:misc
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "misc" is not supported.
|
||||
# _:depends
|
||||
$ fail_solve _:depends
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "depends" is not supported.
|
||||
# _:build
|
||||
$ fail_solve _:build
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "build" is not supported.
|
||||
# _:opamfile
|
||||
$ fail_solve _:opamfile
|
||||
File "$TESTCASE_ROOT/mock-opam-repository/packages/testpkg/testpkg.0.0.1/opam", line 1, characters 0-0:
|
||||
Error: Variable "opamfile" is not supported.
|
||||
Loading…
Add table
Add a link
Reference in a new issue