Skip to content

Commit

Permalink
Merge pull request #8226 from cabalism/test/sdist-multiple-projects-7241
Browse files Browse the repository at this point in the history
Add test cases that reproduce sdist --project-file.
  • Loading branch information
mergify[bot] authored Jan 22, 2024
2 parents 3a55da1 + 1e62b82 commit adc283a
Show file tree
Hide file tree
Showing 92 changed files with 500 additions and 0 deletions.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/p-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
diff --git a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.dot-uv.out b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.dot-uv.out
index 3d6859f99..a7ffc109e 100644
--- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.dot-uv.out
+++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.dot-uv.out
@@ -1,2 +1,2 @@
# cabal sdist
-Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/p-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/uv-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Test.Cabal.Prelude

-- cabal.dot-uv.project has "packages: .". That package is uv.cabal but "cabal
-- sdist" writes sdist/p-0.1.tar.gz instead of the expected sdist/uv-0.1.tar.gz.
-- That is wrong, "cabal sdist" should respect the "--project-file" option but
-- instead probes the parent directory and picks up "../cabal.project" that has
-- "packages: Projects-Default-No/p".
--
-- TODO: Fix this behaviour and apply the patch cabal.dot-uv.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "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/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 sdist
Wrote tarball sdist to <ROOT>/cabal.ignore-project.dist/work/./dist/sdist/uv-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/uv-0.1.tar.gz for the uv.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 /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 sdist
Wrote tarball sdist to <ROOT>/cabal.no-project.dist/work/./dist/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 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 sdist" would work on the local
-- uv.cabal package.
main = cabalTest $ do
cabal "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,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,2 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.sub-pq.dist/work/./dist/sdist/p-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
diff --git a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-pq.out b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-pq.out
index c96d15ee6..12dcc1217 100644
--- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-pq.out
+++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-No/cabal.sub-pq.out
@@ -1,2 +1,3 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.sub-pq.dist/work/./dist/sdist/p-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.sub-pq.dist/work/./dist/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: p/ q/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Test.Cabal.Prelude

-- cabal.sub-pq.project has "packages: p/ q/" but "cabal sdist" only writes
-- sdist/p-0.1.tar.gz instead of the expected sdist/p-0.1.tar.gz and
-- sdist/q-0.1.tar.gz. That is wrong, "cabal sdist" should respect the
-- "--project-file" option but instead probes the parent directory and picks up
-- "../cabal.project" that has "packages: Projects-Default-No/p".
--
-- TODO: Fix this behaviour and apply the patch cabal.sub-pq.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
cabal "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,2 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/p-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git 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
index 3a0a8e5f4..b4cced990 100644
--- 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,2 +1,3 @@
# cabal sdist
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/p-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/r-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/s-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: r/ s/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Test.Cabal.Prelude

-- cabal.sub-rs.project has "packages: r/ s/" but "cabal sdist" writes
-- sdist/p-0.1.tar.gz instead of the expected sdist/r-0.1.tar.gz and
-- sdist/s-0.1.tar.gz. That is wrong, "cabal sdist" should respect the
-- "--project-file" option but instead probes the parent directory and picks up
-- "../cabal.project" that has "packages: Projects-Default-No/p".
--
-- TODO: Fix this behaviour and apply the patch cabal.sub-rs.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "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"]
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: p
version: 0.1
build-type: Simple
cabal-version: >= 1.2

library
exposed-modules: P
build-depends: base
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: q
version: 0.1
build-type: Simple
cabal-version: >= 1.2

library
exposed-modules: Q
build-depends: base
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: r
version: 0.1
build-type: Simple
cabal-version: >= 1.2

library
exposed-modules: R
build-depends: base
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: s
version: 0.1
build-type: Simple
cabal-version: >= 1.2

library
exposed-modules: S
build-depends: base
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cabal-version: 3.0
name: uv
version: 0.1
build-type: Simple

library U
visibility: public
exposed-modules: U
build-depends: base

library V
visibility: public
exposed-modules: V
build-depends: base
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.dot-uv.out b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.dot-uv.out
index 231e0d306..a7ffc109e 100644
--- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.dot-uv.out
+++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.dot-uv.out
@@ -1,3 +1,2 @@
# cabal sdist
-Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/p-0.1.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/q-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.dot-uv.dist/work/./dist/sdist/uv-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Test.Cabal.Prelude

-- cabal.dot-uv.project has "packages: .". That package is uv.cabal but "cabal
-- sdist" writes sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz instead of the
-- expected sdist/uv-0.1.tar.gz. That is wrong, "cabal sdist" should respect
-- the "--project-file" option but instead picks up the default "cabal.project"
-- that has "packages: p/ q/".
--
-- TODO: Fix this behaviour and apply the patch cabal.dot-uv.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
cabal "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,2 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.ignore-project.dist/work/./dist/sdist/uv-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/uv-0.1.tar.gz for the uv.cabal package.
main = cabalTest $ do
cabal "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

-- 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 sdist
Wrote tarball sdist to <ROOT>/cabal.no-project.dist/work/./dist/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/cabal.no-project.dist/work/./dist/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Test.Cabal.Prelude

-- When no project is given, "cabal 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.
--
-- TODO: Check that the code is behaving the same as it would have if
-- "--project-file=cabal.project" was given or if it is using project probing.
main = cabalTest $ do
cabal "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

-- 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 @@
packages: p/ q/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
Wrote tarball sdist to <ROOT>/cabal.project.dist/work/./dist/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/cabal.project.dist/work/./dist/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Test.Cabal.Prelude

-- The given cabal.project has has "packages: p/ q/" and "cabal sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct but likely
-- accidental as the default cabal.project has the same packages.
main = cabalTest . withProjectFile "cabal.project" $ do
cabal "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 sdist
Wrote tarball sdist to <ROOT>/cabal.sub-pq.dist/work/./dist/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/cabal.sub-pq.dist/work/./dist/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: p/ q/
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 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 "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 sdist
Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/q-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.sub-rs.out b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.sub-rs.out
index 264d9e001..b4cced990 100644
--- a/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.sub-rs.out
+++ b/cabal-testsuite/PackageTests/SDist/Respect-Project-File/Projects-Default-Yes/cabal.sub-rs.out
@@ -1,3 +1,3 @@
# cabal sdist
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/p-0.1.tar.gz
-Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/q-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/r-0.1.tar.gz
+Wrote tarball sdist to <ROOT>/cabal.sub-rs.dist/work/./dist/sdist/s-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: r/ s/
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Test.Cabal.Prelude

-- cabal.sub-rs.project has "packages: r/ s/" but "cabal sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz instead of the expected
-- sdist/r-0.1.tar.gz and sdist/s-0.1.tar.gz. That is wrong, "cabal sdist"
-- should respect the "--project-file" option but instead picks up the default
-- "cabal.project" that has "packages: p/ q/".
--
-- TODO: Fix this behaviour and apply the patch cabal.sub-rs.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
cabal "sdist" ["all"]
Loading

0 comments on commit adc283a

Please sign in to comment.