From 7a029caa7026f9b6b585a68062a4175eadb6ca4f Mon Sep 17 00:00:00 2001
From: quasicomputational <quasicomputational@gmail.com>
Date: Wed, 20 Jun 2018 18:10:26 +0100
Subject: [PATCH] Some tests for new-sdist

They're not all passing, but I think that that's a bug in the code
rather than the tests.
---
 Cabal/Distribution/Simple/Utils.hs                 |   1 +
 cabal-install/Distribution/Client/CmdSdist.hs      |  13 +++++++------
 .../PackageTests/NewSdist/MultiTarget/a/Main.hs    |   1 +
 .../PackageTests/NewSdist/MultiTarget/a/Test.hs    |   1 +
 .../PackageTests/NewSdist/MultiTarget/a/a.cabal    |  12 ++++++++++++
 .../NewSdist/MultiTarget/all-output-dir.out        |   3 +++
 .../NewSdist/MultiTarget/all-output-dir.test.hs    |  10 ++++++++++
 .../NewSdist/MultiTarget/all-test-sute.out         |   2 ++
 .../NewSdist/MultiTarget/all-test-sute.test.hs     |   6 ++++++
 .../PackageTests/NewSdist/MultiTarget/all.out      |   3 +++
 .../PackageTests/NewSdist/MultiTarget/all.test.hs  |   6 ++++++
 .../PackageTests/NewSdist/MultiTarget/b/Main.hs    |   1 +
 .../PackageTests/NewSdist/MultiTarget/b/b.cabal    |   7 +++++++
 .../NewSdist/MultiTarget/cabal.project             |   3 +++
 .../MultiTarget/list-sources-output-dir.test.hs    |   8 ++++++++
 .../MultiTarget/multi-archive-to-stdout.out        |   2 ++
 .../MultiTarget/multi-archive-to-stdout.test.hs    |   6 ++++++
 .../NewSdist/MultiTarget/multi-list-sources.out    |   6 ++++++
 .../MultiTarget/multi-list-sources.test.hs         |   4 ++++
 .../NewSdist/MultiTarget/multi-target.out          |   3 +++
 .../NewSdist/MultiTarget/multi-target.test.hs      |   6 ++++++
 .../NewSdist/MultiTarget/target-remote-package.out |   2 ++
 .../MultiTarget/target-remote-package.test.hs      |   5 +++++
 .../NewSdist/MultiTarget/valid-and-test-suite.out  |   2 ++
 .../MultiTarget/valid-and-test-suite.test.hs       |   6 ++++++
 .../PackageTests/NewSdist/NullTerminated/Main.hs   |   1 +
 .../PackageTests/NewSdist/NullTerminated/cabal.out | Bin 0 -> 37 bytes
 .../NewSdist/NullTerminated/cabal.project          |   2 ++
 .../NewSdist/NullTerminated/cabal.test.hs          |   4 ++++
 .../NewSdist/NullTerminated/test.cabal             |   7 +++++++
 30 files changed, 127 insertions(+), 6 deletions(-)
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Main.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/Test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/a/a.cabal
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-output-dir.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/all-test-sute.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/all.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/Main.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/b/b.cabal
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/cabal.project
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/list-sources-output-dir.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-archive-to-stdout.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-list-sources.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/multi-target.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/target-remote-package.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/MultiTarget/valid-and-test-suite.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/NullTerminated/Main.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.out
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.project
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.test.hs
 create mode 100644 cabal-testsuite/PackageTests/NewSdist/NullTerminated/test.cabal

diff --git a/Cabal/Distribution/Simple/Utils.hs b/Cabal/Distribution/Simple/Utils.hs
index ea8caf58bc..1fb2c7b1a5 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 e0d417326a..680c3cfdf5 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 0000000000..e40542c943
--- /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 0000000000..766f9954e6
--- /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 0000000000..4c10ba2b1e
--- /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 0000000000..7c22462695
--- /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 0000000000..73f2ae83dd
--- /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 0000000000..d56882c76a
--- /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 0000000000..1d1dd46b0e
--- /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 0000000000..125d541142
--- /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 0000000000..8b8b715ce3
--- /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 0000000000..c6cd0b9c86
--- /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 0000000000..677a88905a
--- /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 0000000000..cbbfd7d6ee
--- /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 0000000000..89b6c95765
--- /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 0000000000..b5b5552db5
--- /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 0000000000..7087b3fe1b
--- /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 0000000000..11b73eec10
--- /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 0000000000..61eee06fa0
--- /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 0000000000..0870529dcd
--- /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 0000000000..a725a5ffd3
--- /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 0000000000..df24ebe7c0
--- /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 0000000000..6fca30aae5
--- /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 0000000000..803adf5973
--- /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 0000000000..cb1be7c33f
--- /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 0000000000..cfff5fd1aa
--- /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
GIT binary patch
literal 37
pcmY#ZNKQ;j%u&coE!Qnh$t*76@=eUl)5|DkC`m0Y(F02|008Q~3~m4b

literal 0
HcmV?d00001

diff --git a/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.project b/cabal-testsuite/PackageTests/NewSdist/NullTerminated/cabal.project
new file mode 100644
index 0000000000..8834d04402
--- /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 0000000000..82e5d44574
--- /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 0000000000..89bc44e7ef
--- /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
-- 
GitLab