Hegel 0.17.5
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::Settings Struct Reference

Configuration options for hegel::test(). More...

#include <settings.h>

Static Public Member Functions

static Settings from_profile (const std::string &name)

Public Attributes

uint64_t test_cases = resolved_.test_cases
 Number of test cases to run. The base value is 100.
Verbosity verbosity = resolved_.verbosity
 Verbosity level. The base value is Verbosity::Normal.
std::optional< uint64_t > seed = resolved_.seed
bool derandomize = resolved_.derandomize
bool report_multiple_failures = resolved_.report_multiple_failures
bool stop_on_first_failure = resolved_.stop_on_first_failure
NondeterminismStrictness nondeterminism_strictness
bool print_blob = resolved_.print_blob
bool show_statistics = resolved_.show_statistics
bool unbounded_choices = resolved_.unbounded_choices
Database database = resolved_.database
std::optional< std::string > database_key
std::vector< HealthCheck > suppress_health_check
std::vector< Phase > phases = resolved_.phases
Backend backend = resolved_.backend

Detailed Description

Configuration options for hegel::test().

Creating a Settings resolves an engine settings profile and copies every value it resolves: the default profile, or the profile named to Settings::from_profile(). The engine resolves the default profile from hegel::set_default_profile(), the HEGEL_DEFAULT_PROFILE environment variable, and a hegel.toml in the working directory or an ancestor, else from the detected environment (workload inside Antithesis, ci on a CI server, development otherwise). The HEGEL_* settings environment variables then apply over the profile.

Each field that you set replaces the resolved value. Each field that you do not set keeps it:

hegel::Settings settings{.test_cases = 500, .seed = 42};
nightly.test_cases = 10000;
Configuration options for hegel::test().
Definition settings.h:180
static Settings from_profile(const std::string &name)
uint64_t test_cases
Number of test cases to run. The base value is 100.
Definition settings.h:197

The values are fixed when the Settings is created: a profile that hegel::register_profile() or hegel::set_default_profile() changes afterwards does not change it. A malformed hegel.toml or HEGEL_* variable throws std::invalid_argument from the creation.

Member Function Documentation

◆ from_profile()

Settings hegel::Settings::from_profile ( const std::string & name)
static

Settings resolved from the named profile instead of the default one. A name can be reserved (base, default), shipped (development, ci, workload), defined in hegel.toml, or registered with hegel::register_profile().

Parameters
nameThe profile name.
Returns
The settings of that profile.
Exceptions
std::invalid_argumentfor an unknown name, or a malformed hegel.toml or HEGEL_* variable.

Member Data Documentation

◆ backend

Backend hegel::Settings::backend = resolved_.backend

Randomness backend. The base value is Backend::Default; the workload profile selects Backend::Urandom.

◆ database

Database hegel::Settings::database = resolved_.database

Configure the Hegel database. See Database. The base value is Database::default_location(), .hegel/examples; the ci and workload profiles disable the database.

◆ database_key

std::optional<std::string> hegel::Settings::database_key

Key scoping the examples stored in and replayed from the database. A derandomized run also derives its seed from it. Unset, HEGEL_TEST uses "<file>::<name>" of the test, and hegel::test() derives a key as it documents. A run with no key does not store or replay examples.

◆ derandomize

bool hegel::Settings::derandomize = resolved_.derandomize

If true, derive the seed from the database key, so the test is deterministic across executions. The base value is false; the ci profile sets it to true.

◆ nondeterminism_strictness

NondeterminismStrictness hegel::Settings::nondeterminism_strictness
Initial value:
=
resolved_.nondeterminism_strictness

How the run reacts to a test whose outcome or draws change when the same generated data is replayed. The base value is NondeterminismStrictness::Quiet.

◆ phases

std::vector<Phase> hegel::Settings::phases = resolved_.phases

Phases to run, all of them by default. Phases left out of a list are disabled (e.g. drop Phase::Shrink to keep failing examples unshrunk). An empty list ({}) produces a run that does nothing.

◆ print_blob

bool hegel::Settings::print_blob = resolved_.print_blob

If true, the report of each failure ends with the line that replays it from its base64 reproduce blob, at every verbosity. The base value is true.

◆ report_multiple_failures

bool hegel::Settings::report_multiple_failures = resolved_.report_multiple_failures

If true, keep generating after the first failure to surface additional distinct bugs, and report all of them. If false, stop the run at the first failing example. The base value is false.

◆ seed

std::optional<uint64_t> hegel::Settings::seed = resolved_.seed

Explicit seed for the test. The profiles have none by default: each run then picks a fresh seed.

◆ show_statistics

bool hegel::Settings::show_statistics = resolved_.show_statistics

If true, the run prints statistics at its end: for each label recorded with an event, the fraction of test cases it occurred in. The base value is false.

◆ stop_on_first_failure

bool hegel::Settings::stop_on_first_failure = resolved_.stop_on_first_failure

If true, stop generating once a failure is found and move on to shrinking and reporting it. If false, the run uses its whole test_cases budget before reporting, whatever it finds along the way; every distinct failure found is persisted to the database either way. The base value is true.

◆ suppress_health_check

std::vector<HealthCheck> hegel::Settings::suppress_health_check
Initial value:
=
resolved_.suppress_health_check

Health checks to suppress for this test. The profiles suppress none locally, TooSlow on a CI server and all of them inside Antithesis. An empty list ({}) suppresses none.

◆ unbounded_choices

bool hegel::Settings::unbounded_choices = resolved_.unbounded_choices

If true, a test case may make any number of choices. By default the engine stops a test case after 2^20 choices. A long-running test case needs this. The base value is false.


The documentation for this struct was generated from the following file: