Skip to content

Commit

Permalink
Add *.v2.test.hs variants exercising v2-sdist
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Jan 20, 2024
1 parent 6747878 commit 8eeb8b8
Show file tree
Hide file tree
Showing 27 changed files with 138 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/uv-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- cabal.dot-uv.project has "packages: .". That package is uv.cabal and "cabal
-- v2-sdist" writes sdist/uv-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal v2-sdist
Wrote tarball sdist to /home/philderbeast/dev/src/cabalism/cabal/cabal-testsuite/PackageTests/SDist/Respect-Project-File/dist-newstyle/sdist/p-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Test.Cabal.Prelude

-- This test should have written sdist/uv-0.1.tar.gz for the uv.cabal package
-- but instead it probed up the directory tree, found a default cabal.project
-- and wrote sdist/p-0.1.tar.gz. That is incorrect. It didn't ignore the
-- project.
main = cabalTest $ do
cabal "v2-sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal v2-sdist
Wrote tarball sdist to /home/philderbeast/dev/src/cabalism/cabal/cabal-testsuite/PackageTests/SDist/Respect-Project-File/dist-newstyle/sdist/p-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Test.Cabal.Prelude

-- When no project is given, "cabal v2-sdist" probes up the directory tree,
-- finds a default cabal.project and writes sdist/p-0.1.tar.gz. That is
-- acceptable. An alternative and reasonable expectation (but not the behaviour
-- seen) is that project probing would not occur and "cabal v2-sdist" would work
-- on the local uv.cabal package.
main = cabalTest $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- cabal.sub-pq.project has "packages: p/ q/" and "cabal v2-sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/r-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/s-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- cabal.sub-rs.project has "packages: r/ s/" and "cabal v2-sdist" writes
-- sdist/r-0.1.tar.gz and sdist/s-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/uv-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- cabal.dot-uv.project has "packages: .". That package is uv.cabal and "cabal
-- v2-sdist" writes sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. That is correct.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Test.Cabal.Prelude

-- This test doesn't ignore the project. It should have written
-- sdist/uv-0.1.tar.gz for the uv.cabal package but instead it wrote
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz.
main = cabalTest $ do
cabal "v2-sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Test.Cabal.Prelude

-- When no project is given, "cabal v2-sdist" finds a default cabal.project that
-- has "packages: p/ q/" and writes sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz.
-- This is correct.
main = cabalTest $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- The given cabal.project has has "packages: p/ q/" and "cabal v2-sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.project" $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- cabal.sub-pq.project has "packages: p/ q/" and "cabal v2-sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "v2-sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/r-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/s-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- cabal.sub-rs.project has "packages: r/ s/" and "cabal v2-sdist" writes
-- sdist/r-0.1.tar.gz and sdist/s-0.1.tar.gz. That is correct.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "v2-sdist" ["all"]
24 changes: 20 additions & 4 deletions cabal-testsuite/PackageTests/SDist/Respect-Project-File/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,47 @@
$ tree -P '*.project|*.test.hs' --prune
.
├── cabal.ignore-project.test.hs
├── cabal.ignore-project.v2.test.hs
├── cabal.no-project.test.hs
├── cabal.no-project.v2.test.hs
├── cabal.project
├── Projects-Default-No
│   ├── cabal.dot-uv.project
│   ├── cabal.dot-uv.test.hs
│   ├── cabal.dot-uv.v2.test.hs
│   ├── cabal.ignore-project.test.hs
│   ├── cabal.ignore-project.v2.test.hs
│   ├── cabal.no-project.test.hs
│   ├── cabal.no-project.v2.test.hs
│   ├── cabal.sub-pq.project
│   ├── cabal.sub-pq.test.hs
│   ├── cabal.sub-pq.v2.test.hs
│   ├── cabal.sub-rs.project
│   └── cabal.sub-rs.test.hs
│   ├── cabal.sub-rs.test.hs
│   └── cabal.sub-rs.v2.test.hs
└── Projects-Default-Yes
├── cabal.dot-uv.project
├── cabal.dot-uv.test.hs
├── cabal.dot-uv.v2.test.hs
├── cabal.ignore-project.test.hs
├── cabal.ignore-project.v2.test.hs
├── cabal.no-project.test.hs
├── cabal.no-project.v2.test.hs
├── cabal.project
├── cabal.project.test.hs
├── cabal.project.v2.test.hs
├── cabal.sub-pq.project
├── cabal.sub-pq.test.hs
├── cabal.sub-pq.v2.test.hs
├── cabal.sub-rs.project
└── cabal.sub-rs.test.hs
├── cabal.sub-rs.test.hs
└── cabal.sub-rs.v2.test.hs
3 directories, 21 files
3 directories, 34 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
doesn't. This is the default project. There are three important things to notice
with these tests.

1. All the tests with a supplied `--project-file` option pick up a default
Expand Down Expand Up @@ -67,3 +80,6 @@ with these tests.
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.

3. The `*.v2.test.hs` are the same as their `*.test.hs` sibling tests but they
exercise the `v2-sdist` command instead of the `sdist` command.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.ignore-project.v2.dist/work/./dist/sdist/z-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

-- This test correctly writes sdist/z-0.1.tar.gz for the z.cabal package.
main = cabalTest $ do
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Test.Cabal.Prelude

-- When no project is given, "cabal v2-sdist" finds a default cabal.project that
-- has "packages: Projects-Default-No/p" and writes sdist/p-0.1.tar.gz. This is
-- correct.
main = cabalTest $ do
cabal "v2-sdist" ["all"]

0 comments on commit 8eeb8b8

Please sign in to comment.