| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Futhark.Test
Description
Facilities for reading Futhark test programs. A Futhark test program is an ordinary Futhark program where an initial comment block specifies input- and output-sets.
Synopsis
- testSpecFromFile :: FilePath -> IO ProgramTest
- testSpecsFromPaths :: [FilePath] -> IO [(FilePath, ProgramTest)]
- valuesFromByteString :: String -> ByteString -> Either String [Value]
- getValues :: MonadIO m => FilePath -> Values -> m [Value]
- getValuesBS :: MonadIO m => FilePath -> Values -> m ByteString
- compareValues :: [Value] -> [Value] -> [Mismatch]
- compareValues1 :: [Value] -> [Value] -> Maybe Mismatch
- testRunReferenceOutput :: FilePath -> Text -> TestRun -> FilePath
- getExpectedResult :: MonadIO m => FilePath -> Text -> TestRun -> m (ExpectedResult [Value])
- compileProgram :: (MonadIO m, MonadError [Text] m) => [String] -> FilePath -> String -> FilePath -> m (ByteString, ByteString)
- runProgram :: MonadIO m => String -> [String] -> String -> Text -> Values -> m (ExitCode, ByteString, ByteString)
- ensureReferenceOutput :: (MonadIO m, MonadError [Text] m) => FilePath -> String -> FilePath -> [InputOutputs] -> m ()
- data Mismatch
- data ProgramTest = ProgramTest {
- testDescription :: Text
- testTags :: [Text]
- testAction :: TestAction
- data StructureTest = StructureTest StructurePipeline AstMetrics
- data StructurePipeline
- data WarningTest = ExpectedWarning Text Regex
- data TestAction
- data ExpectedError
- data InputOutputs = InputOutputs {
- iosEntryPoint :: Text
- iosTestRuns :: [TestRun]
- data TestRun = TestRun {}
- data ExpectedResult values
- = Succeeds (Maybe values)
- | RunTimeFailure ExpectedError
- data Success
- data Values
- data GenValue
- data Value
Documentation
testSpecFromFile :: FilePath -> IO ProgramTest Source #
Read the test specification from the given Futhark program.
Note: will call error on parse errors.
testSpecsFromPaths :: [FilePath] -> IO [(FilePath, ProgramTest)] Source #
Read test specifications from the given paths, which can be a
files or directories containing .fut files and further
directories. Calls error on parse errors, or if any of the
immediately passed path names do not name a file that exists.
valuesFromByteString :: String -> ByteString -> Either String [Value] Source #
Try to parse a several values from a byte string. The String
parameter is used for error messages.
getValuesBS :: MonadIO m => FilePath -> Values -> m ByteString Source #
Extract a pretty representation of some Values. In the IO
monad because this might involve reading from a file. There is no
guarantee that the resulting byte string yields a readable value.
compareValues :: [Value] -> [Value] -> [Mismatch] Source #
Compare two sets of Futhark values for equality. Shapes and types must also match.
compareValues1 :: [Value] -> [Value] -> Maybe Mismatch Source #
As compareValues, but only reports one mismatch.
testRunReferenceOutput :: FilePath -> Text -> TestRun -> FilePath Source #
When/if generating a reference output file for this run, what should it be called? Includes the "data/" folder.
getExpectedResult :: MonadIO m => FilePath -> Text -> TestRun -> m (ExpectedResult [Value]) Source #
Get the values corresponding to an expected result, if any.
compileProgram :: (MonadIO m, MonadError [Text] m) => [String] -> FilePath -> String -> FilePath -> m (ByteString, ByteString) Source #
runProgram :: MonadIO m => String -> [String] -> String -> Text -> Values -> m (ExitCode, ByteString, ByteString) Source #
ensureReferenceOutput :: (MonadIO m, MonadError [Text] m) => FilePath -> String -> FilePath -> [InputOutputs] -> m () Source #
Ensure that any reference output files exist, or create them (by compiling the program with the reference compiler and running it on the input) if necessary.
Two values differ in some way. The Show instance produces a
human-readable explanation.
data ProgramTest Source #
Description of a test to be carried out on a Futhark program. The Futhark program is stored separately.
Constructors
| ProgramTest | |
Fields
| |
Instances
| Show ProgramTest Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> ProgramTest -> ShowS # show :: ProgramTest -> String # showList :: [ProgramTest] -> ShowS # | |
data StructureTest Source #
A structure test specifies a compilation pipeline, as well as metrics for the program coming out the other end.
Constructors
| StructureTest StructurePipeline AstMetrics |
Instances
| Show StructureTest Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> StructureTest -> ShowS # show :: StructureTest -> String # showList :: [StructureTest] -> ShowS # | |
data StructurePipeline Source #
How a program can be transformed.
Constructors
| KernelsPipeline | |
| SOACSPipeline | |
| SequentialCpuPipeline | |
| GpuPipeline |
Instances
| Show StructurePipeline Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> StructurePipeline -> ShowS # show :: StructurePipeline -> String # showList :: [StructurePipeline] -> ShowS # | |
data WarningTest Source #
A warning test requires that a warning matching the regular expression is produced. The program must also compile succesfully.
Constructors
| ExpectedWarning Text Regex |
Instances
| Show WarningTest Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> WarningTest -> ShowS # show :: WarningTest -> String # showList :: [WarningTest] -> ShowS # | |
data TestAction Source #
How to test a program.
Constructors
| CompileTimeFailure ExpectedError | |
| RunCases [InputOutputs] [StructureTest] [WarningTest] |
Instances
| Show TestAction Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> TestAction -> ShowS # show :: TestAction -> String # showList :: [TestAction] -> ShowS # | |
data ExpectedError Source #
The error expected for a negative test.
Instances
| Show ExpectedError Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> ExpectedError -> ShowS # show :: ExpectedError -> String # showList :: [ExpectedError] -> ShowS # | |
data InputOutputs Source #
Input and output pairs for some entry point(s).
Constructors
| InputOutputs | |
Fields
| |
Instances
| Show InputOutputs Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> InputOutputs -> ShowS # show :: InputOutputs -> String # showList :: [InputOutputs] -> ShowS # | |
A condition for execution, input, and expected result.
Constructors
| TestRun | |
Fields
| |
data ExpectedResult values Source #
How a test case is expected to terminate.
Constructors
| Succeeds (Maybe values) | Execution suceeds, with or without expected result values. |
| RunTimeFailure ExpectedError | Execution fails with this error. |
Instances
| Show values => Show (ExpectedResult values) Source # | |
Defined in Futhark.Test Methods showsPrec :: Int -> ExpectedResult values -> ShowS # show :: ExpectedResult values -> String # showList :: [ExpectedResult values] -> ShowS # | |
The result expected from a succesful execution.
Constructors
| SuccessValues Values | These values are expected. |
| SuccessGenerateValues | Compute expected values from executing a known-good reference implementation. |
Several Values - either literally, or by reference to a file, or to be generated on demand.