tasty-discover-0.0.1: Automatically discover and run Tasty framework tests

Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Run

Description

Where we generate the test running boilerplate. Preprocessor arguments arrive via the main function of Discover.

If you need to make `tasty-discover` do something new, it most likely needs to happen here.

Synopsis

Documentation

run :: [String] -> IO () Source

Accept some args and run the tests

>>> run ["w", "x", "y", "z"]
...

stringifyTestList :: IO [String] -> IO String Source

A list of test function names as a String

>>> stringifyTestList ["prop_one", "prop_two"]
"[\"prop_one\",\"prop_two\"]"

getListOfTests :: FilePath -> IO [String] Source

All test function names in src

>>> getListOfTests "test/Tasty.hs"
["prop_one"]

getTestFiles :: IO [Test] -> IO [FilePath] Source

File paths for test files

>>> getTestFiles $ findTests "test/Tasty.hs"
["test/FooTest.hs"]

findTests :: FilePath -> IO [Test] Source

All tests that are not the src file

>>> findTests "test/Tasty.hs"
[Test {testFile = "test/FooTest.hs", testModule = "Foo"}]

tmpModule :: FilePath -> Config -> [Test] -> String -> String Source

The holy grail. This tmpModule runs your tests

>>> tmpModule "test/Tasty.hs"
              Config {configModuleName = Nothing}
              [Test {testFile = "test/FooTest.hs", testModule = "Foo"}]
              "[\"prop_one\"]"
...

fileToTest :: FilePath -> FilePath -> Maybe Test Source

A test file becomes a Test type

>>> fileToTest "test" "FooTest.hs"
Just (Test {testFile = "test/FooTest.hs", testModule = "Foo"})

getFilesRecursive :: FilePath -> IO [FilePath] Source

All files under baseDir

>>> getFilesRecursive "test/"
["FooTest.hs", "BarTest.hs"]

isValidModuleName :: String -> Bool Source

Is cs a valid Haskell module name?

>>> isValidModuleName "ModName"
True
>>> isValidModuleName "modName"
False

isValidModuleChar :: Char -> Bool Source

Is c a valid character in a Haskell module name?

>>> isValidModuleChar '-'
False
>>> isValidModuleChar 'A'
True

importList :: [Test] -> ShowS Source

Import statements for a list of tests

>>> importList [Test {testFile = "test/SomeOtherTest.hs", testModule = "SomeOther"}]
"import qualified SomeOtherTest\n"