tasty-golden
Golden tests support for tasty
https://github.com/UnkindPartition/tasty-golden
| LTS Haskell 24.29: | 2.3.5 |
| Stackage Nightly 2026-02-05: | 2.3.6 |
| Latest on Hackage: | 2.3.6 |
tasty-golden-2.3.6@sha256:bca7b66bdc0238d63e82164993f684fd7751c95b67a2533088f658840e3400fa,2962Module documentation for 2.3.6
This package provides support for «golden testing».
A golden test is an IO action that writes its result to a file. To pass the test, this output file should be identical to the corresponding «golden» file, which contains the correct result for the test.
To get started with golden testing and this library, see Introduction to golden testing.
Command-line options
To see the command-line options, run your test suite with --help. Here’s an
example output:
Mmm... tasty test suite
Usage: test [-p|--pattern PATTERN] [-t|--timeout DURATION] [-l|--list-tests]
[-j|--num-threads NUMBER] [-q|--quiet] [--hide-successes]
[--color never|always|auto] [--ansi-tricks ARG] [--accept]
[--no-create] [--size-cutoff n]
[--delete-output never|onpass|always]
Available options:
-h,--help Show this help text
-p,--pattern PATTERN Select only tests which satisfy a pattern or awk
expression
-t,--timeout DURATION Timeout for individual tests (suffixes: ms,s,m,h;
default: s)
-l,--list-tests Do not run the tests; just print their names
-j,--num-threads NUMBER Number of threads to use for tests
execution (default: # of cores/capabilities)
-q,--quiet Do not produce any output; indicate success only by
the exit code
--hide-successes Do not print tests that passed successfully
--color never|always|auto
When to use colored output (default: auto)
--ansi-tricks ARG Enable various ANSI terminal tricks. Can be set to
'true' or 'false'. (default: true)
--accept Accept current results of golden tests
--no-create Error when golden file does not exist
--size-cutoff n hide golden test output if it's larger than n
bytes (default: 1000)
--delete-output never|onpass|always
If there is a golden file, when to delete output
files (default: never)
See also tasty’s README.
Maintainers
Roman Cheplyaka is the primary maintainer.
Oliver Charles is the backup maintainer. Please get in touch with him if the primary maintainer cannot be reached.
Changes
Changes
Version 2.3.6
- Option
--no-create-filenow available internally asNoCreateFile(Issue #50) - Drop support for GHC 7, remove obsolete
deriving Typeable - Tested with GHC 8.0 - 9.14.1
Andreas Abel, 2026-02-01
Version 2.3.5
- Fixes for launching external processes (like
diff) on Windows - Update the golden file on
--acceptif decoding the golden file failed with an exception - Do not depend on
unix-compat
Version 2.3.4
- Add an option to remove the output file after a test has run, if there is a golden file, or one has been created
Version 2.3.3.3
- Fix a bug where
goldenVsFileDiffwould not create a missing golden file
Version 2.3.3.2
- Fix a bug where the
TASTY_SIZE_CUTOFFenv. variable would be ignored
Version 2.3.3.1
- Fix a bug with UTF-8 output
Version 2.3.3
- Expose
createDirectoriesAndWriteFile - Add
--size-cutoffto truncate large golden test output - Restore support for GHC >= 7.8
Version 2.3.2.1
Create missing directories when writing golden files
Version 2.3.2
Add a --no-create flag
Version 2.3.1.3
Make the environment variable TASTY_ACCEPT=True work, and make the value
case-insensitive (so TASTY_ACCEPT=true works, too)
Version 2.3.1.2
Docs: link to an introductory blog post
Version 2.3.1.1
Fix compatibility with optparse-applicative-0.13
Version 2.3.1
Intercept exceptions thrown by the test, adhering to the new tasty API contract.
Version 2.3.0.2
Switch from temporary-rc to temporary
Version 2.3.0.1
Impose a lower bound version constraint on bytestring.
Version 2.3
-
Accepting tests is no longer done by a separate ingredient; instead it is now an option that affects tests themselves.
--acceptused to run only golden tests; now all tests are run, but only golden tests are affected by this option- when accepting, all the usual options apply (such as
-j) - when accepting, the interace is the same as when running
defaultMainandacceptingTestsare kept for compatibility, but do not do anything and are obsolete
-
When a golden test file does not exist, it is created automatically, even when
--acceptis not specified. You’ll see a message likeUnboxedTuples: OK (0.04s) Golden file did not exist; created -
No longer use lazy IO
ValueGettertype is gone (replaced byIO)- Because of that, the type of the primitive
goldenTestis changed vgReadFilefunction is gone (replaced byData.ByteString.readFile)
Version 2.2.2.4
- Warn when some tests threw exceptions during
--accept - Properly handle exceptions; don’t swallow Ctrl-C
Version 2.2.2.3
Restore compatibility with older compilers
Version 2.2.2.1
Relax Cabal dependency
Version 2.2.2
Add findByExtension
Version 2.2.1.2
Catch exceptions when accepting golden tests
Version 2.2.1.1
Switch to temporary-rc
Version 2.2.1
- Fix a bug where the result of the comparison function would reference yet unread data from a semiclosed file and the file gets closed, leading to a runtime exception
- Export
writeBinaryFile - Improve the docs
- Update to work with
tasty-0.8
Version 2.2.0.2
Update to work with tasty-0.7
Version 2.2.0.1
Update to work with tasty-0.5
Version 2.2
Migrate to ingredients
Version 2.1
Add goldenVsStringDiff
Version 2.0.1
Update to work with tasty-0.2
Version 2.0
Initial release of tasty-golden (derived from test-framework-golden-1.1.x)