Skip to content

Commit

Permalink
test(pkg): demonstrate unix errors in files directory of opam repo
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Caglayan <[email protected]>
  • Loading branch information
Alizter committed Sep 14, 2023
1 parent c3edae2 commit 991dbe3
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/blackbox-tests/test-cases/pkg/opam-package-files-unix-error.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
This test demonstrates the behaviour when a Unix error is encountered when copying the
files/ directory from a package directory inside an opam repostory.

$ . ./helpers.sh

Generate a mock opam repository
$ mkdir -p mock-opam-repository
$ cat >mock-opam-repository/repo <<EOF
> opam-version: "2.0"
> EOF


Make a package with a patch
$ mkpkg with-patch <<EOF
> opam-version: "2.0"
> EOF

$ fname1="foo.patch"
$ fname2="dir/bar.patch"
$ opam_repo="mock-opam-repository/packages/with-patch/with-patch.0.0.1"
$ mkdir -p $opam_repo/files/dir
$ cat >$opam_repo/files/$fname1 <<EOF
> foo
> EOF
$ cat >$opam_repo/files/$fname2 <<EOF
> bar
> EOF
We remove the read permissions for dir/

$ chmod -r $opam_repo/files/dir

The error message should have a location for the opam repository.

This does not currently seem to be the case.

$ solve_project <<EOF
> (lang dune 3.8)
> (package
> (name x)
> (allow_empty)
> (depends with-patch))
> EOF
Error: Unable to read file in opam repository:
opendir($TESTCASE_ROOT/mock-opam-repository/packages/with-patch/with-patch.0.0.1/files/dir): Permission denied
[1]

Make sure to set permissions back so the sandbox can be cleaned up.

$ chmod +r $opam_repo/files/dir

0 comments on commit 991dbe3

Please sign in to comment.