Skip to content

Commit

Permalink
test(pkg): reproduce not finding the patch file
Browse files Browse the repository at this point in the history
Signed-off-by: Alpha DIALLO <moyodiallo@gmail.com>
  • Loading branch information
moyodiallo committed Sep 23, 2024
1 parent dedfb76 commit 4c096d0
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions test/blackbox-tests/test-cases/pkg/ocamlformat/patch-extra-files.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
This is current bug, 'dune fmt' misses "dev-tools.locks" directory for the first run.

$ . ./helpers.sh
$ mkrepo

Make a fake ocamlformat:
$ mkdir ocamlformat
$ cd ocamlformat
$ cat > dune-project <<EOF
> (lang dune 3.13)
> (package (name ocamlformat))
> EOF
$ cat > ocamlformat.ml <<EOF
> let () = print_string "Hello"
> EOF
$ cat > dune <<EOF
> (executable
> (public_name ocamlformat))
> EOF
$ cd ..
$ tar -czf ocamlformat.tar.gz ocamlformat
$ rm -rf ocamlformat

$ cat > patch-for-ocamlformat.patch <<EOF
> diff a/ocamlformat.ml b/ocamlformat.ml
> --- a/ocamlformat.ml
> +++ b/ocamlformat.ml
> @@ -1,1 +1,1 @@
> -let () = print_string "Hello"
> +let () = print_string "Ocamlformat"
> EOF


Make the ocamlformat opam package which uses a patch:
$ mkpkg ocamlformat "0.26.2" <<EOF
> build: [
> [
> "dune"
> "build"
> "-p"
> name
> "-j"
> jobs
> ]
> ]
> extra-files: ["patch-for-ocamlformat.patch" "md5=$(md5sum patch-for-ocamlformat.patch | cut -f1 -d' ')"]
> patches: ["patch-for-ocamlformat.patch"]
> url {
> src:"file://$PWD/ocamlformat.tar.gz"
> checksum: [
> "md5=$(md5sum ocamlformat.tar.gz | cut -f1 -d' ')"
> ]
> }
> EOF
$ mkdir -p mock-opam-repository/packages/ocamlformat/ocamlformat.0.26.2/files/
$ cp patch-for-ocamlformat.patch mock-opam-repository/packages/ocamlformat/ocamlformat.0.26.2/files/

Make a project that uses the fake ocamlformat:
$ make_project_with_dev_tool_lockdir

First time run
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt 2>&1 | sed -E 's#.*.sandbox/[^/]+#.sandbox/$SANDBOX#g'
Solution for dev-tools.locks/ocamlformat:
- ocamlformat.0.26.2
Error:
.sandbox/$SANDBOX/_private/default/.dev-tool/ocamlformat/ocamlformat/source/patch-for-ocamlformat.patch:
No such file or directory
-> required by
_build/_private/default/.dev-tool/ocamlformat/ocamlformat/target/bin/ocamlformat
-> required by _build/default/.formatted/foo.ml
-> required by alias .formatted/fmt
-> required by alias fmt

Second time run
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt
File "foo.ml", line 1, characters 0-0:
Error: Files _build/default/foo.ml and _build/default/.formatted/foo.ml
differ.
Promoting _build/default/.formatted/foo.ml to foo.ml.
[1]
$ cat foo.ml
Ocamlformat

0 comments on commit 4c096d0

Please sign in to comment.