futhark-0.25.27: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Test.Spec

Description

Definition and parsing of a test specification.

Synopsis

- testSpecFromProgram :: FilePath -> IO (Either String ProgramTest)
- testSpecFromProgramOrDie :: FilePath -> IO ProgramTest
- testSpecsFromPaths :: [FilePath] -> IO (Either String [(FilePath, ProgramTest)])
- testSpecsFromPathsOrDie :: [FilePath] -> IO [(FilePath, ProgramTest)]
- testSpecFromFile :: FilePath -> IO (Either String ProgramTest)
- testSpecFromFileOrDie :: FilePath -> IO ProgramTest
- data ProgramTest = ProgramTest {
  - testDescription :: Text
  - testTags :: [Text]
  - testAction :: TestAction
  }
- data StructureTest = StructureTest StructurePipeline AstMetrics
- data StructurePipeline
  - = GpuPipeline
  - | MCPipeline
  - | SOACSPipeline
  - | SeqMemPipeline
  - | GpuMemPipeline
  - | MCMemPipeline
  - | NoPipeline
- data WarningTest = ExpectedWarning Text Regex
- data TestAction
  - = CompileTimeFailure ExpectedError
  - | RunCases [InputOutputs] [StructureTest] [WarningTest]
- data ExpectedError
  - = AnyError
  - | ThisError Text Regex
- data InputOutputs = InputOutputs {
  - iosEntryPoint :: Text
  - iosTestRuns :: [TestRun]
  }
- data TestRun = TestRun {
  - runTags :: [Text]
  - runInput :: Values
  - runExpectedResult :: ExpectedResult Success
  - runIndex :: Int
  - runDescription :: Text
  }
- data ExpectedResult values
  - = Succeeds (Maybe values)
  - | RunTimeFailure ExpectedError
- data Success
  - = SuccessValues Values
  - | SuccessGenerateValues
- data Values
  - = Values [Value]
  - | InFile FilePath
  - | GenValues [GenValue]
  - | ScriptValues Exp
  - | ScriptFile FilePath
- data GenValue
  - = GenValue ValueType
  - | GenPrim Value
- genValueType :: GenValue -> Text

# Documentation

testSpecFromProgram :: FilePath -> IO (Either String ProgramTest) Source #

Read the test specification from the given Futhark program.

testSpecFromProgramOrDie :: FilePath -> IO ProgramTest Source #

Like `testSpecFromProgram`, but exits the process on error.

testSpecsFromPaths :: [FilePath] -> IO (Either String [(FilePath, ProgramTest)]) Source #

Read test specifications from the given paths, which can be a files or directories containing `.fut` files and further directories.

testSpecsFromPathsOrDie :: [FilePath] -> IO [(FilePath, ProgramTest)] Source #

Like `testSpecsFromPaths`, but kills the process on errors.

testSpecFromFile :: FilePath -> IO (Either String ProgramTest) Source #

Read a test specification from a file. Expects only a single block, and no comment prefixes.

testSpecFromFileOrDie :: FilePath -> IO ProgramTest Source #

Like `testSpecFromFile`, but kills the process on errors.

data ProgramTest Source #

Description of a test to be carried out on a Futhark program. The Futhark program is stored separately.

Constructors

ProgramTest |

Fields

- testDescription :: Text
- testTags :: [Text]
- testAction :: TestAction

#### Instances

Instances details

Show ProgramTest Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> ProgramTest -> ShowS Source # show :: ProgramTest -> String Source # showList :: [ProgramTest] -> ShowS Source #

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

Instances details

Show StructureTest Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> StructureTest -> ShowS Source # show :: StructureTest -> String Source # showList :: [StructureTest] -> ShowS Source #

data StructurePipeline Source #

How a program can be transformed.

Constructors

GpuPipeline |
MCPipeline |
SOACSPipeline |
SeqMemPipeline |
GpuMemPipeline |
MCMemPipeline |
NoPipeline |

#### Instances

Instances details

Show StructurePipeline Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> StructurePipeline -> ShowS Source # show :: StructurePipeline -> String Source # showList :: [StructurePipeline] -> ShowS Source #

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

Instances details

Show WarningTest Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> WarningTest -> ShowS Source # show :: WarningTest -> String Source # showList :: [WarningTest] -> ShowS Source #

data TestAction Source #

How to test a program.

Constructors

CompileTimeFailure ExpectedError |
RunCases [InputOutputs] [StructureTest] [WarningTest] |

#### Instances

Instances details

Show TestAction Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> TestAction -> ShowS Source # show :: TestAction -> String Source # showList :: [TestAction] -> ShowS Source #

data ExpectedError Source #

The error expected for a negative test.

Constructors

AnyError |
ThisError Text Regex |

#### Instances

Instances details

Show ExpectedError Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> ExpectedError -> ShowS Source # show :: ExpectedError -> String Source # showList :: [ExpectedError] -> ShowS Source #

data InputOutputs Source #

Input and output pairs for some entry point(s).

Constructors

InputOutputs |

Fields

- iosEntryPoint :: Text
- iosTestRuns :: [TestRun]

#### Instances

Instances details

Show InputOutputs Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> InputOutputs -> ShowS Source # show :: InputOutputs -> String Source # showList :: [InputOutputs] -> ShowS Source #

data TestRun Source #

A condition for execution, input, and expected result.

Constructors

TestRun |

Fields

- runTags :: [Text]
- runInput :: Values
- runExpectedResult :: ExpectedResult Success
- runIndex :: Int
- runDescription :: Text

#### Instances

Instances details

Show TestRun Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> TestRun -> ShowS Source # show :: TestRun -> String Source # showList :: [TestRun] -> ShowS Source #

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

Instances details

Show values => Show (ExpectedResult values) Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> ExpectedResult values -> ShowS Source # show :: ExpectedResult values -> String Source # showList :: [ExpectedResult values] -> ShowS Source #

data Success Source #

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.

#### Instances

Instances details

Show Success Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> Success -> ShowS Source # show :: Success -> String Source # showList :: [Success] -> ShowS Source #

data Values Source #

Several values - either literally, or by reference to a file, or to be generated on demand. All paths are relative to test program.

Constructors

Values [Value] |
InFile FilePath |
GenValues [GenValue] |
ScriptValues Exp |
ScriptFile FilePath |

#### Instances

Instances details

Show Values Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> Values -> ShowS Source # show :: Values -> String Source # showList :: [Values] -> ShowS Source #

data GenValue Source #

How to generate a single random value.

Constructors

GenValue ValueType | Generate a value of the given rank and primitive type. Scalars are considered 0-ary arrays.
GenPrim Value | A fixed non-randomised primitive value.

#### Instances

Instances details

Show GenValue Source # |
Instance details Defined in Futhark.Test.Spec Methods showsPrec :: Int -> GenValue -> ShowS Source # show :: GenValue -> String Source # showList :: [GenValue] -> ShowS Source #

genValueType :: GenValue -> Text Source #

A prettyprinted representation of type of value produced by a `GenValue`.