-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A fancy test runner, including support for golden tests.
--   
--   This package provides a fancy test runner and support for «golden
--   testing». A golden test is an IO action that writes its result to a
--   file. To pass the test, this output file should be identical to the
--   corresponding «golden» file, which contains the correct result for the
--   test. The test runner allows filtering tests using regexes, and to
--   interactively inspect the result of golden tests. This package is a
--   heavily extended fork of tasty-golden.
@package tasty-silver
@version 3.1.12


-- | Regex filtering for test trees.
module Test.Tasty.Silver.Filter
filterWithRegex :: OptionSet -> TestTree -> TestTree

-- | Check if the given path should be kept using regex filters. A Tree
--   leaf is retained if the following conditions are met: 1. At least one
--   RFInclude matches. 2. No RFExclude filter matches.
checkRF :: Bool -> [RegexFilter] -> TestPath -> Bool
data RegexFilter
RFInclude :: String -> RegexFilter
RFExclude :: String -> RegexFilter

-- | Tests to completely include, treating all other tests like they do not
--   exist.
newtype IncludeFilters
IncludeFilters :: [RegexFilter] -> IncludeFilters

-- | Tests to completely exlucde, treating them like they do not exist.
newtype ExcludeFilters
ExcludeFilters :: [RegexFilter] -> ExcludeFilters
type TestPath = String
instance Test.Tasty.Options.IsOption Test.Tasty.Silver.Filter.IncludeFilters
instance Test.Tasty.Options.IsOption Test.Tasty.Silver.Filter.ExcludeFilters

module Test.Tasty.Silver.Interactive.Run

-- | Provide new test run function wrapping the existing tests.
wrapRunTest :: (forall t. IsTest t => TestPath -> TestName -> OptionSet -> t -> (Progress -> IO ()) -> IO Result) -> TestTree -> TestTree
instance Test.Tasty.Core.IsTest t => Test.Tasty.Core.IsTest (Test.Tasty.Silver.Interactive.Run.CustomTestExec t)

module Test.Tasty.Silver.Internal

-- | See <tt>goldenTest1</tt> for explanation of the fields
data Golden
Golden :: IO (Maybe a) -> IO a -> (a -> a -> IO GDiff) -> (a -> IO GShow) -> Maybe (a -> IO ()) -> Golden

-- | This option, when set to <a>True</a>, specifies that we should run in
--   the «accept tests» mode
newtype AcceptTests
AcceptTests :: Bool -> AcceptTests

-- | Read the file if it exists, else return Nothing. Useful for reading
--   golden files.
readFileMaybe :: FilePath -> IO (Maybe ByteString)

-- | The comparison/diff result.
data GDiff

-- | Values are equal.
Equal :: GDiff

-- | The two values are different, show a diff between the two given texts.
DiffText :: Maybe String -> Text -> Text -> GDiff
[gReason] :: GDiff -> Maybe String
[gActual] :: GDiff -> Text
[gExpected] :: GDiff -> Text

-- | The two values are different, just show the given text to the user.
ShowDiffed :: Maybe String -> Text -> GDiff
[gReason] :: GDiff -> Maybe String
[gDiff] :: GDiff -> Text

-- | How to show a value to the user.
data GShow

-- | Show the given text.
ShowText :: Text -> GShow
type GoldenResult = GoldenResult' IO
type GoldenResultI = GoldenResult' Identity
data GoldenResult' m
GREqual :: GoldenResult' m
GRDifferent :: a -> a -> GDiff -> Maybe (a -> IO ()) -> GoldenResult' m
GRNoGolden :: m a -> (a -> IO GShow) -> Maybe (a -> IO ()) -> GoldenResult' m
runGolden :: Golden -> IO (Result, GoldenResult)
forceGoldenResult :: GoldenResult -> IO GoldenResultI
instance GHC.Classes.Ord Test.Tasty.Silver.Internal.AcceptTests
instance GHC.Classes.Eq Test.Tasty.Silver.Internal.AcceptTests
instance Test.Tasty.Core.IsTest Test.Tasty.Silver.Internal.Golden
instance GHC.Show.Show (Test.Tasty.Silver.Internal.GoldenResult' m)
instance Test.Tasty.Options.IsOption Test.Tasty.Silver.Internal.AcceptTests


-- | Golden test management, interactive mode. Runs the tests, and asks the
--   user how to proceed in case of failure or missing golden standard.
module Test.Tasty.Silver.Interactive

-- | Like <tt>defaultMain</tt> from the main tasty package, but also
--   includes the golden test management capabilities.
defaultMain :: TestTree -> IO ()
defaultMain1 :: [RegexFilter] -> TestTree -> IO ()
interactiveTests :: DisabledTests -> Ingredient
newtype Interactive
Interactive :: Bool -> Interactive

-- | A simple console UI
runTestsInteractive :: DisabledTests -> OptionSet -> TestTree -> IO Bool
instance GHC.Classes.Ord Test.Tasty.Silver.Interactive.UseColor
instance GHC.Classes.Eq Test.Tasty.Silver.Interactive.UseColor
instance GHC.Classes.Ord Test.Tasty.Silver.Interactive.HideSuccesses
instance GHC.Classes.Eq Test.Tasty.Silver.Interactive.HideSuccesses
instance GHC.Show.Show Test.Tasty.Silver.Interactive.FancyTestException
instance GHC.Classes.Eq Test.Tasty.Silver.Interactive.ResultType
instance GHC.Classes.Ord Test.Tasty.Silver.Interactive.Interactive
instance GHC.Classes.Eq Test.Tasty.Silver.Interactive.Interactive
instance GHC.Classes.Ord a => GHC.Base.Semigroup (Test.Tasty.Silver.Interactive.Maximum a)
instance GHC.Classes.Ord a => GHC.Base.Monoid (Test.Tasty.Silver.Interactive.Maximum a)
instance Test.Tasty.Options.IsOption Test.Tasty.Silver.Interactive.UseColor
instance Test.Tasty.Options.IsOption Test.Tasty.Silver.Interactive.HideSuccesses
instance GHC.Base.Semigroup Test.Tasty.Silver.Interactive.FailureStatus
instance GHC.Base.Monoid Test.Tasty.Silver.Interactive.FailureStatus
instance GHC.Base.Semigroup Test.Tasty.Silver.Interactive.TestOutput
instance GHC.Base.Monoid Test.Tasty.Silver.Interactive.TestOutput
instance GHC.Base.Semigroup Test.Tasty.Silver.Interactive.Statistics
instance GHC.Base.Monoid Test.Tasty.Silver.Interactive.Statistics
instance GHC.Exception.Type.Exception Test.Tasty.Silver.Interactive.FancyTestException
instance Test.Tasty.Options.IsOption Test.Tasty.Silver.Interactive.Interactive

module Test.Tasty.Silver.Advanced

-- | A very general testing function.
goldenTest1 :: TestName -> IO (Maybe a) -> IO a -> (a -> a -> GDiff) -> (a -> GShow) -> (a -> IO ()) -> TestTree

-- | A very general testing function. The IO version of show/diff are
--   useful when using external diff or show mechanisms. If IO is not
--   required, the <a>goldenTest1</a> function should be used instead.
goldenTestIO :: TestName -> IO (Maybe a) -> IO a -> (a -> a -> IO GDiff) -> (a -> IO GShow) -> (a -> IO ()) -> TestTree

-- | A very general testing function. Experimental function, may change in
--   later versions! The IO version of show/diff are useful when using
--   external diff or show mechanisms. If IO is not required, the
--   <a>goldenTest1</a> function should be used instead.
goldenTestIO1 :: TestName -> IO (Maybe a) -> IO a -> (a -> a -> IO GDiff) -> (a -> IO GShow) -> Maybe (a -> IO ()) -> TestTree

-- | A very general testing function. Use <a>goldenTest1</a> instead if you
--   can.
goldenTest :: TestName -> IO a -> IO a -> (a -> a -> IO (Maybe String)) -> (a -> IO ()) -> TestTree

-- | How to show a value to the user.
data GShow

-- | Show the given text.
ShowText :: Text -> GShow

-- | The comparison/diff result.
data GDiff

-- | Values are equal.
Equal :: GDiff

-- | The two values are different, show a diff between the two given texts.
DiffText :: Maybe String -> Text -> Text -> GDiff
[gReason] :: GDiff -> Maybe String
[gActual] :: GDiff -> Text
[gExpected] :: GDiff -> Text

-- | The two values are different, just show the given text to the user.
ShowDiffed :: Maybe String -> Text -> GDiff
[gReason] :: GDiff -> Maybe String
[gDiff] :: GDiff -> Text

-- | Read the file if it exists, else return Nothing. Useful for reading
--   golden files.
readFileMaybe :: FilePath -> IO (Maybe ByteString)


-- | This module provides a simplified interface. If you want more, see
--   <a>Test.Tasty.Silver.Advanced</a>.
--   
--   Note about filenames. They are looked up in the usual way, thus
--   relative names are relative to the processes current working
--   directory. It is common to run tests from the package's root directory
--   (via <tt>cabal test</tt> or <tt>cabal install --enable-tests</tt>), so
--   if your test files are under the <tt>tests/</tt> subdirectory, your
--   relative file names should start with <tt>tests/</tt> (even if your
--   <tt>test.hs</tt> is itself under <tt>tests/</tt>, too).
--   
--   Note about line endings. The best way to avoid headaches with line
--   endings (when running tests both on UNIX and Windows) is to treat your
--   golden files as binary, even when they are actually textual.
--   
--   This means:
--   
--   <ul>
--   <li>When writing output files from Haskell code, open them in binary
--   mode (see <tt>openBinaryFile</tt>, <tt>withBinaryFile</tt> and
--   <tt>hSetBinaryMode</tt>). This will disable automatic <tt>\n -&gt;
--   \r\n</tt> conversion on Windows. For convenience, this module exports
--   <tt>writeBinaryFile</tt> which is just like <a>writeFile</a> but opens
--   the file in binary mode. When using <tt>ByteString</tt>s note that
--   <a>Data.ByteString</a> and <a>Data.ByteString.Lazy</a> use binary mode
--   for <tt>writeFile</tt>, while <a>Data.ByteString.Char8</a> and
--   <a>Data.ByteString.Lazy.Char8</a> use text mode.</li>
--   <li>Tell your VCS not to do any newline conversion for golden files.
--   For git check in a <tt>.gitattributes</tt> file with the following
--   contents (assuming your golden files have <tt>.golden</tt>
--   extension):</li>
--   </ul>
--   
--   <pre>
--   *.golden	-text
--   </pre>
--   
--   On its side, tasty-golden reads and writes files in binary mode, too.
--   
--   Why not let Haskell/git do automatic conversion on Windows? Well, for
--   instance, <tt>tar</tt> will not do the conversion for you when
--   unpacking a release tarball, so when you run <tt>cabal install
--   your-package --enable-tests</tt>, the tests will be broken.
--   
--   As a last resort, you can strip all <tt>\r</tt>s from both arguments
--   in your comparison function when necessary. But most of the time
--   treating the files as binary does the job.
module Test.Tasty.Silver

-- | Compare a given file contents against the golden file contents.
--   Assumes that both text files are utf8 encoded.
goldenVsFile :: TestName -> FilePath -> FilePath -> IO () -> TestTree

-- | Compares a given file with the output (exit code, stdout, stderr) of a
--   program. Assumes that the program output is utf8 encoded.
goldenVsProg :: TestName -> FilePath -> FilePath -> [String] -> Text -> TestTree

-- | Compare something text-like against the golden file contents. For the
--   conversion of inputs to text you may want to use the
--   Data.Text.Encoding or/and System.Process.Text modules.
goldenVsAction :: TestName -> FilePath -> IO a -> (a -> Text) -> TestTree

-- | Converts the output of a process produced by e.g. System.Process.Text
--   to a textual representation. Stdout/stderr are written seperately, any
--   ordering relation between the two streams is lost in the translation.
printProcResult :: (ExitCode, Text, Text) -> Text

-- | Find all files in the given directory and its subdirectories that have
--   the given extensions.
--   
--   It is typically used to find all test files and produce a golden test
--   per test file.
--   
--   The returned paths use forward slashes to separate path components,
--   even on Windows. Thus if the file name ends up in a golden file, it
--   will not differ when run on another platform.
--   
--   The semantics of extensions is the same as in <a>takeExtension</a>. In
--   particular, non-empty extensions should have the form <tt>".ext"</tt>.
--   
--   This function may throw any exception that <a>getDirectoryContents</a>
--   may throw.
--   
--   It doesn't do anything special to handle symlinks (in particular, it
--   probably won't work on symlink loops).
--   
--   Nor is it optimized to work with huge directory trees (you'd probably
--   want to use some form of coroutines for that).
findByExtension :: [FilePath] -> FilePath -> IO [FilePath]
