diff --git a/Cabal/Distribution/Simple/Utils.hs b/Cabal/Distribution/Simple/Utils.hs index ea8caf58bc0dcf04c3bfac008fcbe906a41928b9..1fb2c7b1a531dd3cda4079be775d2443b2114eb9 100644 --- a/Cabal/Distribution/Simple/Utils.hs +++ b/Cabal/Distribution/Simple/Utils.hs @@ -40,6 +40,7 @@ module Distribution.Simple.Utils ( chattyTry, annotateIO, printRawCommandAndArgs, printRawCommandAndArgsAndEnv, + withOutputMarker, -- * exceptions handleDoesNotExist, diff --git a/cabal-install/Distribution/Client/CmdSdist.hs b/cabal-install/Distribution/Client/CmdSdist.hs index e0d417326ab4887e9af19df2c77aa53621850c06..680c3cfdf5276eb5a9c322b519e0dd86a0a11a4d 100644 --- a/cabal-install/Distribution/Client/CmdSdist.hs +++ b/cabal-install/Distribution/Client/CmdSdist.hs @@ -45,7 +45,7 @@ import Distribution.Simple.Setup import Distribution.Simple.SrcDist ( listPackageSources ) import Distribution.Simple.Utils - ( die', notice ) + ( die', notice, withOutputMarker ) import Distribution.Types.ComponentName ( ComponentName, showComponentName ) import Distribution.Types.PackageName @@ -177,8 +177,8 @@ sdistAction SdistFlags{..} targetStrings globalFlags = do let format = - if | listSources, nulSeparated -> SourceList '\n' - | listSources -> SourceList '\0' + if | listSources, nulSeparated -> SourceList '\0' + | listSources -> SourceList '\n' | otherwise -> Archive archiveFormat ext = case format of @@ -222,12 +222,13 @@ packageToSdist verbosity format outputFile pkg = do (norm NoExec -> nonexec, norm Exec -> exec) <- listPackageSources verbosity (flattenPackageDescription $ packageDescription pkg) knownSuffixHandlers - let write = if outputFile == "-" then BSL.putStr else BSL.writeFile outputFile + let write = if outputFile == "-" + then putStr . withOutputMarker verbosity . BSL.unpack + else BSL.writeFile outputFile files = nub . sortOn snd $ nonexec ++ exec case format of - SourceList nulSep -> do - notice verbosity $ "File manifest for package " ++ prettyShow (packageId pkg) ++ ":\n" + SourceList nulSep -> write (BSL.pack . (++ [nulSep]) . intercalate [nulSep] . fmap snd $ files) Archive TargzFormat -> do let entriesM :: StateT (Set.Set FilePath) (WriterT [Tar.Entry] IO) () diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Main.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..e40542c94348f62860dce25b8888a00b510d69b8 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Main.hs @@ -0,0 +1 @@ +main = putStrLn "a" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Test.hs new file mode 100644 index 0000000000000000000000000000000000000000..766f9954e6f837d248a29134357d59c495b8a1d6 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Test.hs @@ -0,0 +1 @@ +main = putStrLn "a-test" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/a.cabal b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/a.cabal new file mode 100644 index 0000000000000000000000000000000000000000..4c10ba2b1ebab5359bb2c23c9aea88697ed1609c --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/a.cabal @@ -0,0 +1,12 @@ +cabal-version: 2.2 +name: a +version: 0.1 + +executable a + default-language: Haskell2010 + main-is: Main.hs + +test-suite a-tests + default-language: Haskell2010 + main-is: Test.hs + type: exitcode-stdio-1.0 diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.out new file mode 100644 index 0000000000000000000000000000000000000000..7c224626950127961994b085892de2b1d2a7a9a6 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.out @@ -0,0 +1,3 @@ +# cabal new-sdist +Wrote tarball sdist to <ROOT>/all-output-dir.dist/source/archives/a-0.1.tar.gz +Wrote tarball sdist to <ROOT>/all-output-dir.dist/source/archives/b-0.1.tar.gz diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..73f2ae83dd22dca9815043867e3bd4ef13e11d0c --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.test.hs @@ -0,0 +1,10 @@ +import Test.Cabal.Prelude +import System.Directory +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + liftIO $ createDirectoryIfMissing False $ cwd </> "archives" + cabal "new-sdist" ["all", "--output-dir", "archives"] + shouldNotExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" + shouldNotExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" + shouldExist $ cwd </> "archives/a-0.1.tar.gz" + shouldExist $ cwd </> "archives/b-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.out new file mode 100644 index 0000000000000000000000000000000000000000..d56882c76a2cdb2b26a7aaae82a3559eec2d9aff --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.out @@ -0,0 +1,2 @@ +# cabal new-sdist +cabal: It is not possible to package only the test suites from a package for distribution. Only entire packages may be packaged for distribution. diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..1d1dd46b0ea424931df2596122c7597680fa6457 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + fails $ cabal "new-sdist" ["all:tests"] + shouldNotExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" + shouldNotExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.out new file mode 100644 index 0000000000000000000000000000000000000000..125d541142a26135019c48a070fbad13fbc48178 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.out @@ -0,0 +1,3 @@ +# cabal new-sdist +Wrote tarball sdist to <ROOT>/all.dist/source/dist-newstyle/sdist/a-0.1.tar.gz +Wrote tarball sdist to <ROOT>/all.dist/source/dist-newstyle/sdist/b-0.1.tar.gz diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..8b8b715ce3257a911add194ed5394ab0310d5b55 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + cabal "new-sdist" ["all"] + shouldExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" + shouldExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/Main.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..c6cd0b9c86dd94600f71f1383c15753e057ce667 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/Main.hs @@ -0,0 +1 @@ +main = putStrLn "b" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/b.cabal b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/b.cabal new file mode 100644 index 0000000000000000000000000000000000000000..677a88905a4a4936078b3cbfdbf54bb9c4147552 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/b.cabal @@ -0,0 +1,7 @@ +cabal-version: 2.2 +name: b +version: 0.1 + +executable b + default-language: Haskell2010 + main-is: Main.hs diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/cabal.project b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/cabal.project new file mode 100644 index 0000000000000000000000000000000000000000..cbbfd7d6eedef701cdc30d5f3bfdebf3d4911573 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/cabal.project @@ -0,0 +1,3 @@ +packages: + a/ + b/ diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..89b6c957658f1b7910f698b3c8d196b6e4cbfa09 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.test.hs @@ -0,0 +1,8 @@ +import Test.Cabal.Prelude +import System.Directory +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + liftIO $ createDirectoryIfMissing False $ cwd </> "lists" + cabal "new-sdist" ["all", "--list-only", "--output-dir", "lists"] + assertFindInFile "a/a.cabal" (cwd </> "lists/a-0.1.list") + assertFindInFile "b/b.cabal" (cwd </> "lists/b-0.1.list") diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.out new file mode 100644 index 0000000000000000000000000000000000000000..b5b5552db5eee0d884eba40e5041d133dfbb228f --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.out @@ -0,0 +1,2 @@ +# cabal new-sdist +cabal: Can't write multiple tarballs to standard output! diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..7087b3fe1b09a26d47e28f6beb9bf4dc8ab68ac4 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + fails $ cabal "new-sdist" ["a", "b", "--output-dir", "-"] + shouldNotExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" + shouldNotExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.out new file mode 100644 index 0000000000000000000000000000000000000000..11b73eec10bd7b2f33227724c2b25e9400b6d48a --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.out @@ -0,0 +1,6 @@ +# cabal new-sdist +a/Main.hs +a/Test.hs +a/a.cabal +b/Main.hs +b/b.cabal diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..61eee06fa0bcb80dfaefbfd81d44cb08457ae63f --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.test.hs @@ -0,0 +1,4 @@ +import Test.Cabal.Prelude +import Data.List +main = cabalTest $ withSourceCopy $ + cabal "new-sdist" ["a", "b", "--list-only"] diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.out new file mode 100644 index 0000000000000000000000000000000000000000..0870529dcd99503b5d0594e5fbcfd01d35752c54 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.out @@ -0,0 +1,3 @@ +# cabal new-sdist +Wrote tarball sdist to <ROOT>/multi-target.dist/source/dist-newstyle/sdist/a-0.1.tar.gz +Wrote tarball sdist to <ROOT>/multi-target.dist/source/dist-newstyle/sdist/b-0.1.tar.gz diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..a725a5ffd3d1b1dc710708dae646aa751f3e1c82 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + cabal "new-sdist" ["a", "b"] + shouldExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" + shouldExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.out new file mode 100644 index 0000000000000000000000000000000000000000..df24ebe7c0285b17e865439e8a37d3645c7231ec --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.out @@ -0,0 +1,2 @@ +# cabal new-sdist +cabal: The package base cannot be packaged for distribution, because it is not local to this project. diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..6fca30aae5d5ba9534e4127232526ada7a4176c1 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.test.hs @@ -0,0 +1,5 @@ +import Test.Cabal.Prelude +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + fails $ cabal "new-sdist" ["a", "base"] + shouldNotExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.out b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.out new file mode 100644 index 0000000000000000000000000000000000000000..803adf59737295a2ff89cdf4fb7e27a19514954a --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.out @@ -0,0 +1,2 @@ +# cabal new-sdist +cabal: The package a-test cannot be packaged for distribution, because it is not local to this project. diff --git a/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..cb1be7c33f82490aca6711f6f861a10606fe3df7 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs @@ -0,0 +1,6 @@ +import Test.Cabal.Prelude +main = cabalTest $ withSourceCopy $ do + cwd <- testCurrentDir <$> getTestEnv + fails $ cabal "new-sdist" ["a", "b", "a-test"] + shouldNotExist $ cwd </> "dist-newstyle/sdist/a-0.1.tar.gz" + shouldNotExist $ cwd </> "dist-newstyle/sdist/b-0.1.tar.gz" diff --git a/cabal-testsuite/PackageTests/NewSdist/NullTerminated/Main.hs b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/Main.hs new file mode 100644 index 0000000000000000000000000000000000000000..cfff5fd1aaa5d750f9da4f024cba36a122cb0219 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/Main.hs @@ -0,0 +1 @@ +main = putStrLn "Main.hs" diff --git a/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.out b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.out new file mode 100644 index 0000000000000000000000000000000000000000..69e74f4190c391cd2b4ee25aceb9e7c6bc2b8996 Binary files /dev/null and b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.out differ diff --git a/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.project b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.project new file mode 100644 index 0000000000000000000000000000000000000000..8834d04402a2a77a2fa0c4f718102dc0b450cbce --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.project @@ -0,0 +1,2 @@ +packages: + ./ diff --git a/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.test.hs b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.test.hs new file mode 100644 index 0000000000000000000000000000000000000000..82e5d44574393387fcefd7cdb6d4f17e86b5ce85 --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.test.hs @@ -0,0 +1,4 @@ +import Test.Cabal.Prelude +import Data.List +main = cabalTest $ + cabal "new-sdist" ["--list-only", "--null"] diff --git a/cabal-testsuite/PackageTests/NewSdist/NullTerminated/test.cabal b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/test.cabal new file mode 100644 index 0000000000000000000000000000000000000000..89bc44e7ef6c78db9d0b5eb3d3d08faf1e74d11d --- /dev/null +++ b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/test.cabal @@ -0,0 +1,7 @@ +cabal-version: 2.2 +name: test +version: 0.1 + +executable a + default-language: Haskell2010 + main-is: Main.hs