Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/SDist/ListSources/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = return ()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blah
11 changes: 11 additions & 0 deletions cabal-testsuite/PackageTests/SDist/ListSources/list-sources.cabal
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cabal sdist
List of package sources written to file '<TMPDIR>/sources'
List of package sources written to file '<TMPDIR>/sources'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Setup sdist
List of package sources written to file '<TMPDIR>/sources'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Control.Monad.IO.Class
import System.FilePath (normalise)
import Test.Cabal.Prelude
main = setupTest $ do
tmpdir <- fmap testTmpDir getTestEnv
let fn = tmpdir </> "sources"
setup "sdist" ["--list-sources=" ++ fn]
liftIO $ putStrLn =<< readFile 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"
10 changes: 9 additions & 1 deletion cabal-testsuite/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import System.Exit
import System.FilePath
import System.IO
import System.IO.Error (isDoesNotExistError)
import System.IO.Temp (withSystemTempDirectory)
import System.Process hiding (env)
import Options.Applicative
import Text.Regex
Expand Down Expand Up @@ -232,7 +233,7 @@ diffProgram = simpleProgram "diff"

-- | Run a test in the test monad according to program's arguments.
runTestM :: String -> TestM a -> IO a
runTestM mode m = do
runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
args <- execParser (info testArgParser mempty)
let dist_dir = testArgDistDir args
(script_dir0, script_filename) = splitFileName (testArgScriptPath args)
Expand Down Expand Up @@ -300,6 +301,7 @@ runTestM mode m = do
Just _ -> [GlobalPackageDB]
env = TestEnv {
testSourceDir = script_dir,
testTmpDir = tmp_dir,
testSubName = script_base,
testMode = mode,
testProgramDb = program_db,
Expand Down Expand Up @@ -409,6 +411,7 @@ normalizeOutput nenv =
-- string search-replace. Make sure we do this before backslash
-- normalization!
. resub (posixRegexEscape (normalizerRoot nenv)) "<ROOT>/"
. resub (posixRegexEscape (normalizerTmpDir nenv)) "<TMPDIR>/"
. appEndo (F.fold (map (Endo . packageIdRegex) (normalizerKnownPackages nenv)))
-- Look for foo-0.1/installed-0d6...
-- These installed packages will vary depending on GHC version
Expand All @@ -435,6 +438,7 @@ normalizeOutput nenv =

data NormalizerEnv = NormalizerEnv {
normalizerRoot :: FilePath,
normalizerTmpDir :: FilePath,
normalizerGhcVersion :: Version,
normalizerKnownPackages :: [PackageId],
normalizerPlatform :: Platform
Expand All @@ -451,6 +455,8 @@ mkNormalizerEnv = do
return NormalizerEnv {
normalizerRoot
= addTrailingPathSeparator (testSourceDir env),
normalizerTmpDir
= addTrailingPathSeparator (testTmpDir env),
normalizerGhcVersion
= compilerVersion (testCompiler env),
normalizerKnownPackages
Expand Down Expand Up @@ -505,6 +511,8 @@ data TestEnv = TestEnv
-- | Path to the test directory, as specified by path to test
-- script.
testSourceDir :: FilePath
-- | Somewhere to stow temporary files needed by the test.
, testTmpDir :: FilePath
-- | Test sub-name, used to qualify dist/database directory to avoid
-- conflicts.
, testSubName :: String
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/cabal-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ library
filepath,
regex-compat-tdfa,
regex-tdfa,
temporary,
text,
Cabal >= 2.3
ghc-options: -Wall -fwarn-tabs
Expand Down