-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(pkg): reproduce not finding the patch file (dune fmt
)
#10947
Open
moyodiallo
wants to merge
3
commits into
ocaml:main
Choose a base branch
from
moyodiallo:test-for-bug-extra-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-patch-extra-files.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'dune fmt' produce lock files inside "dev-tools.locks/ocamlformat" before it starts building | ||
ocamlformat and its dependencies during the same run of the "dune fmt" command. The source tree is | ||
loaded before the lock files are produced, this is why any 'patch' file inside | ||
'dev-tools.locks/ocmalformat' is not copied inside the 'build' directory when a rule depends on it. | ||
|
||
In the case of this issue, there is a rule that depends on an 'patch' file in order to copy the file | ||
inside '_private/default/..' directory, since the file could not be copied, the rule is not activated. | ||
So it fails when 'dune' trying to apply the patch. After any follwing run of 'dune fmt', it works | ||
because the 'patch' file is already present. | ||
|
||
$ . ./helpers.sh | ||
$ mkrepo | ||
|
||
Make a fake ocamlformat: | ||
$ make_fake_ocamlformat "0.1" | ||
|
||
$ cat > patch-for-ocamlformat.patch <<EOF | ||
> diff a/ocamlformat.ml b/ocamlformat.ml | ||
> --- a/ocamlformat.ml | ||
> +++ b/ocamlformat.ml | ||
> @@ -1,6 +1,6 @@ | ||
> -let version = "0.1" | ||
> +let version = "0.26.2" | ||
> let () = | ||
> if Sys.file_exists ".ocamlformat-ignore" then | ||
> print_endline "ignoring some files" | ||
> ;; | ||
> let () = print_endline ("formatted with version "^version) | ||
> 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-0.1.tar" | ||
> checksum: [ | ||
> "md5=$(md5sum ocamlformat-0.1.tar | 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 run of 'dune fmt' | ||
$ 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 | ||
|
||
The second run will works because the 'patch' is already in the source. | ||
$ ls dev-tools.locks/ocamlformat/ocamlformat.files | ||
patch-for-ocamlformat.patch | ||
|
||
Second run of 'dune fmt' | ||
$ 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 | ||
formatted with version 0.26.2 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you actually need the solving step? Can't you write a fake lock directory for ocamlformat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we need it. The bug is when the solving step is done during the fisrt run of
dune fmt
and if you have already the lock directory it won't trigger the bug.