ouroboros-consensus-test-0.3.1.0: Tests of the consensus layer
Safe HaskellNone
LanguageHaskell2010

Test.Util.Serialisation.Golden

Description

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 ouroboros-network.nix:

 # Command-line options for test suites:
 packages.ouroboros-consensus-byron-test.components.tests.test.testFlags =
   lib.mkForce [ "-- >no-create" ];
 packages.ouroboros-consensus-shelley-test.components.tests.test.testFlags =
   lib.mkForce [ "-- >no-create" ];
 packages.ouroboros-consensus-cardano-test.components.tests.test.testFlags =
   lib.mkForce [ "-- >no-create" ];

In particular, if we introduce golden tests in different suites, we need to add a line in the nix configuration above similar to the previous ones, eg:

packages.some-new-package.components.tests.test.testFlags =
   lib.mkForce [ "-- >no-create" ];
Synopsis

Documentation

type Labelled a = [(Maybe String, a)] Source #

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.

Minimal complete definition

Nothing

Methods

toGoldenDirectory ∷ a → FilePath Source #

default toGoldenDirectoryShow a ⇒ a → FilePath Source #

combineExamples ∷ ∀ blk. (∀ a. Labelled a → Labelled a → Labelled a) → Examples blk → Examples blk → Examples blk Source #

goldenTest_all Source #

Arguments

∷ (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.

labelled ∷ [(String, a)] → Labelled a Source #

mapExamples ∷ ∀ blk. (∀ a. Labelled a → Labelled a) → Examples blk → Examples blk Source #

prefixExamplesStringExamples blk → Examples blk Source #

Add the given prefix to each labelled example.

When a label is empty, the prefix is used as the label. If the label is not empty, the prefix and _ are prepended.

Orphan instances

Condense TermToken Source # 
Instance details

Methods

condense ∷ TermToken → String Source #