Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Golden tests infrastructure.
Golden tests are implemented using tasty-golden.
When adding a new golden test, running the test suite locally will generate the golden files. These files should be checked in as CI will fail if there are missing golden files.
Failing a golden test suite when the corresponding golden files are not found
is done via the --no-create
flag, which surprisingly is opt-in. In our
nix
infrastructure, this flag for CI is set in nix/haskell.nix
.
testFlags = lib.mkForce [ "--no-create" ];
In particular, if we introduce golden tests in new suites, we need to add a line in the nix configuration above similar to the previous ones.
Synopsis
- class ToGoldenDirectory a where
- toGoldenDirectory ∷ a → FilePath
- goldenTest_SerialiseDisk ∷ ∀ blk. (SerialiseDiskConstraints blk, HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree
- goldenTest_SerialiseNodeToClient ∷ ∀ blk. (SerialiseNodeToClientConstraints blk, SupportedNetworkProtocolVersion blk, ToGoldenDirectory (QueryVersion, BlockNodeToClientVersion blk), HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree
- goldenTest_SerialiseNodeToNode ∷ ∀ blk. (SerialiseNodeToNodeConstraints blk, SupportedNetworkProtocolVersion blk, ToGoldenDirectory (BlockNodeToNodeVersion blk), HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree
- goldenTest_all ∷ (SerialiseDiskConstraints blk, SerialiseNodeToNodeConstraints blk, SerialiseNodeToClientConstraints blk, SupportedNetworkProtocolVersion blk, ToGoldenDirectory (BlockNodeToNodeVersion blk), ToGoldenDirectory (QueryVersion, BlockNodeToClientVersion blk), HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree
Documentation
class ToGoldenDirectory a where Source #
Convert a
to a FilePath
that can be used as the directory containing
golden output files.
This class allows overriding the Show
in cases where that output is not
suitable to be used as a directory.
For example, the Show
output for a hard fork enabled NodeToNodeVersion
will contain colons, asterisks, spaces, parentheses, ... and other
characters that we don't want to use for a directory name. For instance
colons cannot be used in Windows file/folder names.
Nothing
toGoldenDirectory ∷ a → FilePath Source #
default toGoldenDirectory ∷ Show a ⇒ a → FilePath Source #
goldenTest_SerialiseDisk ∷ ∀ blk. (SerialiseDiskConstraints blk, HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree Source #
goldenTest_SerialiseNodeToClient ∷ ∀ blk. (SerialiseNodeToClientConstraints blk, SupportedNetworkProtocolVersion blk, ToGoldenDirectory (QueryVersion, BlockNodeToClientVersion blk), HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree Source #
goldenTest_SerialiseNodeToNode ∷ ∀ blk. (SerialiseNodeToNodeConstraints blk, SupportedNetworkProtocolVersion blk, ToGoldenDirectory (BlockNodeToNodeVersion blk), HasCallStack) ⇒ CodecConfig blk → FilePath → Examples blk → TestTree Source #
∷ (SerialiseDiskConstraints blk, SerialiseNodeToNodeConstraints blk, SerialiseNodeToClientConstraints blk, SupportedNetworkProtocolVersion blk, ToGoldenDirectory (BlockNodeToNodeVersion blk), ToGoldenDirectory (QueryVersion, BlockNodeToClientVersion blk), HasCallStack) | |
⇒ CodecConfig blk | |
→ FilePath | Path relative to the root of the repository that contains the golden files |
→ Examples blk | |
→ TestTree |
Golden tests for all things we serialise to disk and send across the network.
Exceptions: when an encoder throws an exception, which can happen when
serialising a Shelley header in combination with
CardanoNodeToNodeVersion1
, we show
the exception and use that as the
output.