Function fail::cfg[][src]

pub fn cfg<S: Into<String>>(name: S, actions: &str) -> Result<(), String>

Configure the actions for a fail point at runtime.

Each fail point can be configured with a series of actions, specified by the actions argument. The format of actions is action[->action...]. When multiple actions are specified, an action will be checked only when its former action is not triggered.

The format of a single action is [p%][cnt*]task[(arg)]. p% is the expected probability that the action is triggered, and cnt* is the max times the action can be triggered. The supported values of task are:

For example, 20%3*print(still alive!)->panic means the fail point has 20% chance to print a message “still alive!” and 80% chance to panic. And the message will be printed at most 3 times.

The FAILPOINTS environment variable accepts this same syntax for its fail point actions.

A call to cfg with a particular fail point name overwrites any existing actions for that fail point, including those set via the FAILPOINTS environment variable.