This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,38 @@
Test that the "dune ocaml doc" command causes odoc to be
locked, built and run when the command is run from a dune project with
a lockdir containing an "ocaml" lockfile.
$ . ../helpers.sh
$ . ./helpers.sh
$ mkrepo
$ make_mock_odoc_package
$ mkpkg ocaml 5.2.0
$ setup_odoc_workspace
$ cat > dune-project <<EOF
> (lang dune 3.16)
>
> (package
> (name foo)
> (allow_empty))
> EOF
$ make_lockdir
$ cat > dune.lock/ocaml.pkg <<EOF
> (version 5.2.0)
> EOF
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune ocaml doc
Solution for dev-tools.locks/odoc:
- ocaml.5.2.0
- odoc.0.0.1
hello from fake odoc
hello from fake odoc
File "_doc/_html/_unknown_", line 1, characters 0-0:
Error: Rule failed to produce directory "_doc/_html/odoc.support"
File "_doc/_odoc/pkg/foo/_unknown_", line 1, characters 0-0:
Error: Rule failed to generate the following targets:
- _doc/_odoc/pkg/foo/page-index.odoc
[1]

View file

@ -0,0 +1,15 @@
Exercise the behaviour of "dune ocaml doc" when run in a
dune project with no lockdir.
$ cat > dune-project <<EOF
> (lang dune 3.16)
>
> (package
> (name foo)
> (allow_empty))
> EOF
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune ocaml doc
Error: Unable to load the lockdir for the default build context.
Hint: Try running 'dune pkg lock'
[1]

View file

@ -0,0 +1,20 @@
Exercise the behaviour of "dune ocaml doc" when the lockdir
doesn't contain a lockfile for the "ocaml" package.
$ . ../helpers.sh
$ cat > dune-project <<EOF
> (lang dune 3.16)
>
> (package
> (name foo)
> (allow_empty))
> EOF
$ make_lockdir
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune ocaml doc
Error: The lockdir doesn't contain a lockfile for the package "ocaml".
Hint: Add a dependency on "ocaml" to one of the packages in dune-project and
then run 'dune pkg lock'
[1]

View file

@ -0,0 +1,78 @@
Test that if the version of the "ocaml" package in the project's
lockdir changes then the odoc dev tool is re-locked to be built
with the version of the ocaml compiler now in the project's
lockdir. This is necessary because odoc must be compiled with the
same version of the ocaml compiler as the code that it's analyzing.
$ . ../helpers.sh
$ . ./helpers.sh
$ mkrepo
$ make_mock_odoc_package
$ mkpkg ocaml 5.2.0
$ mkpkg ocaml 5.1.0
$ setup_odoc_workspace
$ cat > dune-project <<EOF
> (lang dune 3.16)
>
> (package
> (name foo)
> (allow_empty))
> EOF
$ make_lockdir
$ cat > dune.lock/ocaml.pkg <<EOF
> (version 5.2.0)
> EOF
Initially odoc will be depend on ocaml.5.2.0 to match the project.
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune ocaml doc
Solution for dev-tools.locks/odoc:
- ocaml.5.2.0
- odoc.0.0.1
hello from fake odoc
hello from fake odoc
File "_doc/_html/_unknown_", line 1, characters 0-0:
Error: Rule failed to produce directory "_doc/_html/odoc.support"
File "_doc/_odoc/pkg/foo/_unknown_", line 1, characters 0-0:
Error: Rule failed to generate the following targets:
- _doc/_odoc/pkg/foo/page-index.odoc
[1]
$ cat dev-tools.locks/odoc/ocaml.pkg
(version 5.2.0)
We can re-run "dune ocaml doc" without relocking or rebuilding.
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune ocaml doc
hello from fake odoc
hello from fake odoc
File "_doc/_html/_unknown_", line 1, characters 0-0:
Error: Rule failed to produce directory "_doc/_html/odoc.support"
File "_doc/_odoc/pkg/foo/_unknown_", line 1, characters 0-0:
Error: Rule failed to generate the following targets:
- _doc/_odoc/pkg/foo/page-index.odoc
[1]
Change the version of ocaml that the project depends on.
$ cat > dune.lock/ocaml.pkg <<EOF
> (version 5.1.0)
> EOF
Running "dune ocaml doc" causes odoc to be relocked and rebuilt
before running. Odoc now depends on ocaml.5.1.0.
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune ocaml doc
The version of the compiler package ("ocaml") in this project's lockdir has
changed to 5.1.0 (formerly the compiler version was 5.2.0). The dev-tool
"odoc" will be re-locked and rebuilt with this version of the compiler.
Solution for dev-tools.locks/odoc:
- ocaml.5.1.0
- odoc.0.0.1
hello from fake odoc
hello from fake odoc
File "_doc/_html/_unknown_", line 1, characters 0-0:
Error: Rule failed to produce directory "_doc/_html/odoc.support"
File "_doc/_odoc/pkg/foo/_unknown_", line 1, characters 0-0:
Error: Rule failed to generate the following targets:
- _doc/_odoc/pkg/foo/page-index.odoc
[1]

View file

@ -0,0 +1,3 @@
(cram
(deps helpers.sh)
(applies_to :whole_subtree))

View file

@ -0,0 +1,27 @@
# Create a dune-workspace file with mock repos set up for the main
# project and the odoc lockdir.
setup_odoc_workspace() {
cat > dune-workspace <<EOF
(lang dune 3.16)
(lock_dir
(path "dev-tools.locks/odoc")
(repositories mock))
(lock_dir
(repositories mock))
(repository
(name mock)
(url "file://$(pwd)/mock-opam-repository"))
EOF
}
# Create a fake odoc package containing an executable that
# just prints a message.
make_mock_odoc_package() {
mkpkg odoc <<EOF
install: [
[ "sh" "-c" "echo '#!/bin/sh' > %{bin}%/odoc" ]
[ "sh" "-c" "echo 'echo hello from fake odoc' >> %{bin}%/odoc" ]
[ "sh" "-c" "chmod a+x %{bin}%/odoc" ]
]
EOF
}