From 218c7bfc8e42e888bdd151ca0c22394959006c66 Mon Sep 17 00:00:00 2001 From: quasicomputational Date: Sat, 28 Apr 2018 15:43:24 +0100 Subject: [PATCH] Rudimentary test for sdist --list-sources. --- .../PackageTests/SDist/ListSources/Main.hs | 1 + .../PackageTests/SDist/ListSources/data/blah/a.dat | 1 + .../SDist/ListSources/extra-doc/blah/a.tex | 1 + .../SDist/ListSources/extra-src/blah/a.html | 1 + .../PackageTests/SDist/ListSources/list-sources.cabal | 11 +++++++++++ .../SDist/ListSources/list-sources.cabal.out | 3 +++ .../PackageTests/SDist/ListSources/list-sources.out | 2 ++ .../SDist/ListSources/list-sources.test.hs | 10 ++++++++++ 8 files changed, 30 insertions(+) create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/Main.hs create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/data/blah/a.dat create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/extra-doc/blah/a.tex create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/extra-src/blah/a.html create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal.out create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/list-sources.out create mode 100644 cabal-testsuite/PackageTests/SDist/ListSources/list-sources.test.hs diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/Main.hs b/cabal-testsuite/PackageTests/SDist/ListSources/Main.hs new file mode 100644 index 00000000000..b3549c2fe3d --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/Main.hs @@ -0,0 +1 @@ +main = return () diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/data/blah/a.dat b/cabal-testsuite/PackageTests/SDist/ListSources/data/blah/a.dat new file mode 100644 index 00000000000..907b308167f --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/data/blah/a.dat @@ -0,0 +1 @@ +blah diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/extra-doc/blah/a.tex b/cabal-testsuite/PackageTests/SDist/ListSources/extra-doc/blah/a.tex new file mode 100644 index 00000000000..907b308167f --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/extra-doc/blah/a.tex @@ -0,0 +1 @@ +blah diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/extra-src/blah/a.html b/cabal-testsuite/PackageTests/SDist/ListSources/extra-src/blah/a.html new file mode 100644 index 00000000000..907b308167f --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/extra-src/blah/a.html @@ -0,0 +1 @@ +blah diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal new file mode 100644 index 00000000000..c0c0abfb781 --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal @@ -0,0 +1,11 @@ +cabal-version: 2.2 +name: list-sources +version: 0 +data-dir: data +data-files: blah/*.dat +extra-source-files: extra-src/blah/*.html +extra-doc-files: extra-doc/blah/*.tex + +executable dummy + default-language: Haskell2010 + main-is: Main.hs diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal.out b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal.out new file mode 100644 index 00000000000..2482a13d897 --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal.out @@ -0,0 +1,3 @@ +# cabal sdist +List of package sources written to file '/sources' +List of package sources written to file '/sources' diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.out b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.out new file mode 100644 index 00000000000..c7b1ba4eaa2 --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.out @@ -0,0 +1,2 @@ +# Setup sdist +List of package sources written to file '/sources' diff --git a/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.test.hs b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.test.hs new file mode 100644 index 00000000000..c3cf82c2b1b --- /dev/null +++ b/cabal-testsuite/PackageTests/SDist/ListSources/list-sources.test.hs @@ -0,0 +1,10 @@ +import System.FilePath (normalise) +import Test.Cabal.Prelude +main = setupTest $ do + tmpdir <- fmap testTmpDir getTestEnv + let fn = tmpdir "sources" + setup "sdist" ["--list-sources=" ++ fn] + -- --list-sources outputs with slashes on posix and backslashes on Windows. 'normalise' converts our needle to the necessary format. + assertFileDoesContain fn $ normalise "data/blah/a.dat" + assertFileDoesContain fn $ normalise "extra-src/blah/a.html" + assertFileDoesContain fn $ normalise "extra-doc/blah/a.tex"