Skip to content
Closed
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
53 changes: 48 additions & 5 deletions cabal-testsuite/src/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,45 @@
{-# LANGUAGE NondecreasingIndentation #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-duplicate-exports #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-}

-- | Generally useful definitions that we expect most test scripts
-- to use.
module Test.Cabal.Prelude
( module Test.Cabal.Prelude
( -- * Assertions

-- ** Assert Marked Output
-- $marked-output
assertOutputContains
, assertOutputDoesNotContain
, assertOutputMatches
, assertOutputDoesNotMatch
, assertOn

-- ** Assert File
, assertFileDoesContain
, assertFileDoesNotContain
, assertFindInFile
, assertAnyFileContains
, assertNoFileContains

-- ** Assert Glob
, assertGlobMatches
, assertGlobDoesNotMatch
, assertGlobMatchesTestDir
, assertGlobDoesNotMatchTestDir

-- ** Other Assertions
, assertBool
, assertEqual
, assertExitCode
, assertFailure
, assertNotEqual
, assertRegex

-- * Re-exports
, module Test.Cabal.Prelude
, module Test.Cabal.Monad
, module Test.Cabal.NeedleHaystack
, module Test.Cabal.Run
Expand Down Expand Up @@ -36,9 +69,6 @@ import Distribution.Simple.Configure
import Distribution.Simple.PackageDescription (readGenericPackageDescription)
import Distribution.Simple.Program
import Distribution.Simple.Utils
( tryFindPackageDesc
, withFileContents
)
import Distribution.System (Arch (JavaScript), OS (Linux, OSX, Windows), buildArch, buildOS)
import Distribution.Types.LocalBuildInfo
import Distribution.Utils.Path
Expand Down Expand Up @@ -67,7 +97,7 @@ import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Lazy as BSL
import qualified Data.Char as Char
import Data.List (isInfixOf, isPrefixOf, stripPrefix)
import Data.List (isPrefixOf, stripPrefix)
import Data.Maybe (fromMaybe, isJust, mapMaybe)
import Network.Wait (waitTcpVerbose)
import System.Directory
Expand All @@ -85,6 +115,19 @@ import System.Process
import System.Posix.Resource
#endif

-- $marked-output
-- When asserting on the output of a command we only have access to the marked
-- output. That is the output between these markers:
--
-- @
-- -----BEGIN CABAL OUTPUT-----
-- -----END CABAL OUTPUT-----
-- @
--
-- This is the output from 'notice' and `warn` messages. It does not include the
-- output from `debug` or `info` messages. This is mostly because the output
-- from `debug` and `info` messages is not expected to be deterministic.

------------------------------------------------------------------------

-- * Utilities
Expand Down
Loading