Repository navigation
fix: cabal sdist target selection (#11385)
#12440
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
Open
blackheaven
wants to merge
2
commits into
haskell:master
Choose a base branch
from
blackheaven:fix/sdist-selector
base: master
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
2 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 hidden or 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
6 changes: 4 additions & 2 deletions
6
cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.out
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # cabal v2-sdist | ||
| Error: [Cabal-7151] | ||
| The component test suite 'a-tests' cannot be packaged for distribution on its own. Only entire packages may be packaged for distribution. | ||
| Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/a-0.1.tar.gz | ||
| Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/b-0.1.tar.gz | ||
| # cabal v2-sdist | ||
| Wrote source list to <ROOT>/lists/a-0.1.list |
15 changes: 12 additions & 3 deletions
15
cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,15 @@ | ||
| import Test.Cabal.Prelude | ||
| import System.Directory (createDirectoryIfMissing) | ||
| import System.FilePath (normalise) | ||
| main = cabalTest $ do | ||
| cwd <- fmap testCurrentDir getTestEnv | ||
| fails $ cabal "v2-sdist" ["a", "b", "a-tests"] | ||
| shouldNotExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" | ||
| shouldNotExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" | ||
| liftIO $ createDirectoryIfMissing False $ cwd </> "lists" | ||
| cabal "v2-sdist" ["a", "b", "a-tests"] | ||
| shouldExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" | ||
| shouldExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" | ||
|
|
||
| -- Duplicate selectors resolving to the same package must yield a single | ||
| -- package, not two copies of the archive (#11385). With --list-only the | ||
| -- deduped package is written to a single .list file. | ||
| cabal "v2-sdist" ["a", "a-tests", "--list-only", "--output-dir", "lists"] | ||
| assertFindInFile (normalise "a/a.cabal") (cwd </> "lists/a-0.1.list") |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/NewSdist/SubDirPackageTarget/cabal.project
This file contains hidden or 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 @@ | ||
| packages: p/ |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/NewSdist/SubDirPackageTarget/p/P.hs
This file contains hidden or 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 @@ | ||
| module P where |
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/NewSdist/SubDirPackageTarget/p/p.cabal
This file contains hidden or 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,7 @@ | ||
| cabal-version: 2.2 | ||
| name: p | ||
| version: 0.1 | ||
|
|
||
| library | ||
| default-language: Haskell2010 | ||
| exposed-modules: P |
8 changes: 8 additions & 0 deletions
8
cabal-testsuite/PackageTests/NewSdist/SubDirPackageTarget/subdir-target.out
This file contains hidden or 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,8 @@ | ||
| # cabal v2-sdist | ||
| Configuration is affected by cabal.project at '<GBLTMPDIR>'. | ||
| Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz | ||
| # cabal v2-sdist | ||
| Configuration is affected by cabal.project at '<GBLTMPDIR>'. | ||
| Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz | ||
| # cabal v2-sdist | ||
| Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz |
10 changes: 10 additions & 0 deletions
10
cabal-testsuite/PackageTests/NewSdist/SubDirPackageTarget/subdir-target.test.hs
This file contains hidden or 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,10 @@ | ||
| import Test.Cabal.Prelude | ||
| main = cabalTest $ do | ||
| cwd <- fmap testCurrentDir getTestEnv | ||
| -- #11385: bare package name typed inside the package directory | ||
| withDirectory "p" $ cabal "v2-sdist" ["p"] | ||
| -- explicit component form selects the containing package | ||
| withDirectory "p" $ cabal "v2-sdist" ["p:lib:p"] | ||
| -- package name from the project root keeps working | ||
| cabal "v2-sdist" ["p"] | ||
| shouldExist $ cwd </> "dist-newstyle/sdist/p-0.1.tar.gz" |
This file contains hidden or 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,18 @@ | ||
| --- | ||
| synopsis: "`cabal sdist <pkg>` works when run inside the package directory" | ||
| packages: [cabal-install] | ||
| prs: 12440 | ||
| issues: 11385 | ||
| --- | ||
|
|
||
| `cabal sdist <pkgname>` failed with `[Cabal-7151] The component library cannot be | ||
| packaged for distribution on its own` when run inside the package directory, | ||
| because a bare package name resolves to the package's primary library component. | ||
| Any target selector referring to a component (or a module or file within a | ||
| component) of a local package now selects that package, so `cabal sdist <pkg>`, | ||
| `cabal sdist <pkg>:lib:<pkg>` and similar forms package the containing package. | ||
| Explicit component-kind filters such as `cabal sdist tests` still fail with | ||
| `[Cabal-7151]`. Multiple selectors resolving to the same package (e.g. | ||
| `cabal sdist a a-tests`) now produce a single archive per package instead of | ||
| duplicates, and `cabal sdist a a-tests --output-dir -` writes one tarball to | ||
| standard output rather than failing with `[Cabal-7152]`. |
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.
Uh oh!
There was an error while loading. Please reload this page.