Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- run :: [String] -> IO ()
- data Test
- stringifyTestList :: IO [String] -> IO String
- getListOfTests :: FilePath -> IO [String]
- getTestFiles :: IO [Test] -> IO [FilePath]
- findTests :: FilePath -> IO [Test]
- tmpModule :: FilePath -> Config -> [Test] -> String -> String
- fileToTest :: FilePath -> FilePath -> Maybe Test
- getFilesRecursive :: FilePath -> IO [FilePath]
- isValidModuleName :: String -> Bool
- isValidModuleChar :: Char -> Bool
- importList :: [Test] -> ShowS
- testFile :: Test -> FilePath
- testModule :: Test -> String
- defaultConfig :: Config
Documentation
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"
testModule :: Test -> String Source