drasil-testing-kit-0.0.1: A framework for code and document generation for scientific software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Drasil.TestingKit.Golden

Description

A golden testing suite based on tasty-golden, specialized to FileLayout and prioritizing checking diffs of whole directories:

https://hackage-content.haskell.org/package/tasty-golden-2.3.6

Run your test suite with --accept to accept files as the new golden tests.

Synopsis

Documentation

goldenTestingGroup Source #

Arguments

:: OsPath

The relative directory where newly generated files should be written.

-> OsPath

The relative directory where the expected/golden files are stored.

-> TestName

The name of the test group (e.g., "Golden Tests").

-> [GoldenTestCase]

A list of golden test cases to run.

-> TestTree 

Create a golden testing group relative to a main build folder and golden artifacts folder.

data GoldenTestCase Source #

A golden test case.

goldenTest :: TestName -> FileLayout -> GoldenTestCase Source #

Create a golden test case for a given FileLayout. Within the context of a goldenTestingGroup, will be dumped to the build folder and compared with the golden artifacts folder.

data OverwritePolicy #

When writing files or creating directories, is overwriting allowed?

data FileLayout #

Container for laying out files in a single container for writing to disk. Notes:

  1. Polymorphic over the representation of the file contents. For rendering, writeFiles requires the file content representation satisfy Writeable.
  2. Only permits writing files/directories relative to a base path provided. Does not permit `..`, ., nor ~ as directory names.
  3. System-local path separator is forbidden from use in directory names.
  4. Assumes host file system is case-sensitive (i.e., recognizes txt and `a.txt` as different paths).

directory :: Foldable f => PathSegment -> f FileLayout -> FileLayout #

Create a directory FileLayout, optionally containing any number of nested files.

localPath :: OsPath #

toPath :: PathSegment -> OsPath #

Retrieve OsPath representation of a PathSegment.

ps :: QuasiQuoter #

QuasiQuoter for building PathSegments.

Syntax: ps ::= comp+ comp ::= '{' hsVar '}' | <any string excl. ., '..', ~, not including the system-local path sep.> hsVar ::= string

name :: FileLayout -> PathSegment #

Get the top-level name (a PathSegment) of a FileLayout.

file :: Writeable doc => PathSegment -> doc -> FileLayout #

Create a file FileLayout. When written, this file will have a /trailing newline always added/. Use exactFile for building raw files. This is primarily for synthetic files/generated ones.

exactFile :: Writeable doc => PathSegment -> doc -> FileLayout #

Create a file FileLayout containing the exact file contents.

writeFiles :: OverwritePolicy -> OsPath -> FileLayout -> IO () #

Write a FileLayout to disk about a base path.

If the given OverwritePolicy is NeverOverwrite, this will fail if the top-level target path already exists. If it is OverwriteAllowed, it will overwrite existing files.

Disclaimer: For case-insensitive file systems where different paths in the layout might reference the same on-disk path, this code will fail.