Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
1923b4a8
Commit
1923b4a8
authored
Jun 20, 2018
by
quasicomputational
Committed by
Alexis Williams
Jun 24, 2018
Browse files
Fix up the new-sdist tests.
parent
7a029caa
Changes
12
Hide whitespace changes
Inline
Side-by-side
Cabal/doc/nix-local-build.rst
View file @
1923b4a8
...
...
@@ -488,7 +488,8 @@ and two archives of the same format built from the same source will hash to the
``
cabal
new
-
sdist
``
takes
the
following
flags
:
-
``-
l
``,
``--
list
-
only
``:
Rather
than
creating
an
archive
,
lists
files
that
would
be
included
.
Output
is
to
``
stdout
``
by
default
.
Output
is
to
``
stdout
``
by
default
.
The
file
paths
are
relative
to
the
project
's root
directory.
- ``--targz``: Output an archive in ``.tar.gz`` format.
...
...
cabal-install/Distribution/Client/CmdSdist.hs
View file @
1923b4a8
...
...
@@ -79,7 +79,7 @@ import System.Directory
(
getCurrentDirectory
,
setCurrentDirectory
,
createDirectoryIfMissing
,
makeAbsolute
)
import
System.FilePath
(
(
</>
),
(
<.>
),
normalise
,
takeDirectory
)
(
(
</>
),
(
<.>
),
makeRelative
,
normalise
,
takeDirectory
)
sdistCommand
::
CommandUI
SdistFlags
sdistCommand
=
CommandUI
...
...
@@ -202,7 +202,7 @@ sdistAction SdistFlags{..} targetStrings globalFlags = do
|
length
pkgs
>
1
,
not
listSources
,
Just
"-"
<-
mOutputPath'
->
die'
verbosity
"Can't write multiple tarballs to standard output!"
|
otherwise
->
mapM_
(
\
pkg
->
packageToSdist
verbosity
format
(
outputPath
pkg
)
pkg
)
pkgs
mapM_
(
\
pkg
->
packageToSdist
verbosity
(
distProjectRootDirectory
distLayout
)
format
(
outputPath
pkg
)
pkg
)
pkgs
data
IsExec
=
Exec
|
NoExec
deriving
(
Show
,
Eq
)
...
...
@@ -211,8 +211,8 @@ data OutputFormat = SourceList Char
|
Archive
ArchiveFormat
deriving
(
Show
,
Eq
)
packageToSdist
::
Verbosity
->
OutputFormat
->
FilePath
->
UnresolvedSourcePackage
->
IO
()
packageToSdist
verbosity
format
outputFile
pkg
=
do
packageToSdist
::
Verbosity
->
FilePath
->
OutputFormat
->
FilePath
->
UnresolvedSourcePackage
->
IO
()
packageToSdist
verbosity
projectRootDir
format
outputFile
pkg
=
do
dir
<-
case
packageSource
pkg
of
LocalUnpackedPackage
path
->
return
path
_
->
die'
verbosity
"The impossible happened: a local package isn't local"
...
...
@@ -226,10 +226,13 @@ packageToSdist verbosity format outputFile pkg = do
then
putStr
.
withOutputMarker
verbosity
.
BSL
.
unpack
else
BSL
.
writeFile
outputFile
files
=
nub
.
sortOn
snd
$
nonexec
++
exec
prefix
=
makeRelative
projectRootDir
dir
case
format
of
SourceList
nulSep
->
write
(
BSL
.
pack
.
(
++
[
nulSep
])
.
intercalate
[
nulSep
]
.
fmap
snd
$
files
)
SourceList
nulSep
->
do
write
(
BSL
.
pack
.
(
++
[
nulSep
])
.
intercalate
[
nulSep
]
.
fmap
((
prefix
</>
)
.
snd
)
$
files
)
when
(
outputFile
/=
"-"
)
$
notice
verbosity
$
"Wrote source list to "
++
outputFile
++
"
\n
"
Archive
TargzFormat
->
do
let
entriesM
::
StateT
(
Set
.
Set
FilePath
)
(
WriterT
[
Tar
.
Entry
]
IO
)
()
entriesM
=
forM_
files
$
\
(
perm
,
file
)
->
do
...
...
@@ -257,7 +260,8 @@ packageToSdist verbosity format outputFile pkg = do
(
first
,
rest
)
=
BSL
.
splitAt
9
bs
rest'
=
BSL
.
tail
rest
write
.
normalize
.
GZip
.
compress
.
Tar
.
write
$
entries
notice
verbosity
$
"Wrote tarball sdist to "
++
outputFile
++
"
\n
"
when
(
outputFile
/=
"-"
)
$
notice
verbosity
$
"Wrote tarball sdist to "
++
outputFile
++
"
\n
"
Archive
ZipFormat
->
do
entries
<-
forM
files
$
\
(
perm
,
file
)
->
do
let
perm'
=
case
perm
of
...
...
cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
import
System.Directory
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
testCurrentDir
getTestEnv
liftIO
$
createDirectoryIfMissing
False
$
cwd
</>
"archives"
cabal
"new-sdist"
[
"all"
,
"--output-dir"
,
"archives"
]
shouldNotExist
$
cwd
</>
"dist-newstyle/sdist/a-0.1.tar.gz"
...
...
cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
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"
cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
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"
cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.out
0 → 100644
View file @
1923b4a8
# cabal new-sdist
Wrote source list to <ROOT>/list-sources-output-dir.dist/source/lists/a-0.1.list
Wrote source list to <ROOT>/list-sources-output-dir.dist/source/lists/b-0.1.list
cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
import
System.Directory
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
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"
)
...
...
cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
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"
cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
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"
cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
testCurrentDir
getTestEnv
fails
$
cabal
"new-sdist"
[
"a"
,
"base"
]
shouldNotExist
$
cwd
</>
"dist-newstyle/sdist/a-0.1.tar.gz"
cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs
View file @
1923b4a8
import
Test.Cabal.Prelude
main
=
cabalTest
$
withSourceCopy
$
do
cwd
<-
testCurrentDir
<$>
getTestEnv
cwd
<-
fmap
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"
cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.out
View file @
1923b4a8
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment