Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import Test.Cabal.Prelude
--
-- TODO: Fix this behaviour and apply the patch cabal.dot-uv.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Test.Cabal.Prelude

-- This test correctly writes sdist/uv-0.1.tar.gz for the uv.cabal package.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import Test.Cabal.Prelude
-- alternative and reasonable expectation (but not the behaviour seen) is that
-- project probing would not occur and "cabal sdist" would work on the local
-- uv.cabal package.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import Test.Cabal.Prelude
--
-- TODO: Fix this behaviour and apply the patch cabal.sub-pq.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import Test.Cabal.Prelude
--
-- TODO: Fix this behaviour and apply the patch cabal.sub-rs.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import Test.Cabal.Prelude
--
-- TODO: Fix this behaviour and apply the patch cabal.dot-uv.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ do
main = cabalTest . withProjectFile "cabal.dot-uv.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Test.Cabal.Prelude

-- This test correctly writes sdist/uv-0.1.tar.gz for the uv.cabal package.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# cabal v2-sdist
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/p-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/q-0.1.tar.gz
Wrote tarball sdist to <ROOT>/dist-newstyle/sdist/uv-0.1.tar.gz
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Test.Cabal.Prelude

-- This test doesn't ignore the project. It should have written
-- sdist/uv-0.1.tar.gz for the uv.cabal package but instead it wrote
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz.
-- With "--ignore-project", "cabal v2-sdist" ignores the default cabal.project
-- that has "packages: p/ q/" and writes sdist/uv-0.1.tar.gz for the uv.cabal
-- package in the current directory. This is correct.
main = cabalTest $ do
cabal "v2-sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import Test.Cabal.Prelude
--
-- TODO: Check that the code is behaving the same as it would have if
-- "--project-file=cabal.project" was given or if it is using project probing.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import Test.Cabal.Prelude
-- The given cabal.project has has "packages: p/ q/" and "cabal sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct but likely
-- accidental as the default cabal.project has the same packages.
main = cabalTest . withProjectFile "cabal.project" $ do
main = cabalTest . withProjectFile "cabal.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import Test.Cabal.Prelude

-- cabal.sub-pq.project has "packages: p/ q/" and "cabal sdist" writes
-- sdist/p-0.1.tar.gz and sdist/q-0.1.tar.gz. This is correct.
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ do
main = cabalTest . withProjectFile "cabal.sub-pq.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import Test.Cabal.Prelude
--
-- TODO: Fix this behaviour and apply the patch cabal.sub-rs.patch to update the
-- expected output to what we'd expect if "cabal sdist" respected the project.
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ do
main = cabalTest . withProjectFile "cabal.sub-rs.project" $ expectBroken 12501 $ do
cabal "sdist" ["all"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Test.Cabal.Prelude

-- This test correctly writes sdist/z-0.1.tar.gz for the z.cabal package.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Test.Cabal.Prelude

-- This test correctly writes sdist/z-0.1.tar.gz for the z.cabal package.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all", "--ignore-project"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import Test.Cabal.Prelude
-- When no project is given, "cabal sdist" finds a default cabal.project that
-- has "packages: Projects-Default-No/p" and writes sdist/p-0.1.tar.gz. This is
-- correct.
main = cabalTest $ do
main = cabalTest $ expectBroken 12501 $ do
cabal "sdist" ["all"]
4 changes: 3 additions & 1 deletion cabal-testsuite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ Otherwise, here is a walkthrough:
with the exception of one test stored in `tests`.)

2. Create one or more `.test.hs` scripts in your directory, using
the template:
the template below. The name may contain further dots, as in
`cabal.no-project.test.hs`; the part before `.test.hs` names the
test's `.out` and `.dist` files.
```haskell
import Test.Cabal.Prelude
main = setupAndCabalTest $ do
Expand Down
9 changes: 4 additions & 5 deletions cabal-testsuite/main/cabal-tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,10 @@ partitionTests testPattern paths =

go ts ms [] = (keepPatternMatches ts, keepPatternMatches ms)
go ts ms (f:fs) =
-- NB: Keep this synchronized with isTestFile
case takeExtensions f of
".test.hs" -> go (f:ts) ms fs
".multitest.hs" -> go ts (f:ms) fs
_ -> go ts ms fs
case testFileKind f of
Just SingleTest -> go (f:ts) ms fs
Just MultiTest -> go ts (f:ms) fs
Nothing -> go ts ms fs

outputThread :: Verbosity -> Chan ServerLogMsg -> Handle -> IO ()
outputThread verbosity chan log_handle = go ""
Expand Down
23 changes: 17 additions & 6 deletions cabal-testsuite/src/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module Test.Cabal.Monad
, TestM
, runTestM

-- * Test scripts
, TestFileKind (..)
, testFileKind

-- * Helper functions
, programPathM
, requireProgramM
Expand Down Expand Up @@ -593,13 +597,20 @@ withSourceCopy m = do
else copyFile (curdir </> f) (dest </> f)
m

-- NB: Keep this synchronized with partitionTests
-- | How the harness treats a file, judged by its name alone.
data TestFileKind = SingleTest | MultiTest

-- | A test script is any file ending in @.test.hs@ or @.multitest.hs@. The
-- name may contain further dots, e.g. @cabal.no-project.test.hs@; the part
-- before the suffix names the test's @.out@ and @.dist@ files.
testFileKind :: FilePath -> Maybe TestFileKind
testFileKind f
| ".multitest.hs" `isExtensionOf` f = Just MultiTest
| ".test.hs" `isExtensionOf` f = Just SingleTest
| otherwise = Nothing

isTestFile :: FilePath -> Bool
isTestFile f =
case takeExtensions f of
".test.hs" -> True
".multitest.hs" -> True
_ -> False
isTestFile = isJust . testFileKind

initWorkDir :: TestM ()
initWorkDir = do
Expand Down
Loading