Skip to content

Commit

Permalink
Add a readme for the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 15, 2023
1 parent 3cc1016 commit d36901c
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions cabal-testsuite/PackageTests/SDist/Respect-Project-File/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Tests of sdist with `--project-file`

```
$ tree -P '*.project|*.test.hs' --prune
.
├── cabal.ignore-project.test.hs
├── cabal.no-project.test.hs
├── cabal.project
├── Projects-Default-No
│   ├── cabal.dot-uv.project
│   ├── cabal.dot-uv.test.hs
│   ├── cabal.ignore-project.test.hs
│   ├── cabal.no-project.test.hs
│   ├── cabal.sub-pq.project
│   ├── cabal.sub-pq.test.hs
│   ├── cabal.sub-rs.project
│   └── cabal.sub-rs.test.hs
└── Projects-Default-Yes
├── cabal.dot-uv.project
├── cabal.dot-uv.test.hs
├── cabal.ignore-project.test.hs
├── cabal.no-project.test.hs
├── cabal.project
├── cabal.project.test.hs
├── cabal.sub-pq.project
├── cabal.sub-pq.test.hs
├── cabal.sub-rs.project
└── cabal.sub-rs.test.hs
3 directories, 21 files
```

There are of the two subdirectories, one has a `cabal.project` and the other
doesn't. This is the default project. There are two important things to notice
with these tests.

1. All the tests with a supplied `--project-file` option pick up a default
`cabal.project` instead; either the one one in the current directory or the
one from the parent directory, one level up. I think this behaviour is wrong
and the supplied `--project-file` option should be respected.

Before I'd put a project there, one level up, the project probing had gone
all the way up to Cabal's own `cabal.project` as can be seen by this diff
after that change:

```
$ git diff
...
--- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-rs.out
+++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-rs.out
@@ -1,12 +1,2 @@
# cabal sdist
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-testsuite-3.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-syntax-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-install-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-install-solver-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/solver-benchmarks-3.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-QuickCheck-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-tree-diff-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-described-3.11.0.0.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/Cabal-tests-3.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/cabal-benchmarks-3.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/p-0.1.tar.gz
```
2. The `--ignore-project` option works, as witnessed by each
`cabal.ignore-project.test.hs` when the package in the same directory as the
test is used. Note the parse failure when sublibraries are used. I think we
could provide a better error message there:
```
$ cabal sdist
...
Errors encountered when parsing cabal file ./uv.cabal:
uv.cabal:8:22: error:
unexpected "u"
7 | visibility: public
8 | exposed-modules: U.u
| ^
```

0 comments on commit d36901c

Please sign in to comment.