From 4f3a9547e54a48d154e52d8d335c6b1d089f4334 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 28 Jun 2023 12:48:24 -0400 Subject: [PATCH] feat: add skip cheatcode docs (#938) --- src/SUMMARY.md | 1 + src/cheatcodes/README.md | 3 +++ src/cheatcodes/skip.md | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/cheatcodes/skip.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 825980bea..0bf7cad41 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -280,6 +280,7 @@ - [Utilities](./cheatcodes/utilities.md) - [`addr`](./cheatcodes/addr.md) - [`sign`](./cheatcodes/sign.md) + - [`skip`](./cheatcodes/skip.md) - [`label`](./cheatcodes/label.md) - [`deriveKey`](./cheatcodes/derive-key.md) - [`parseBytes`](./cheatcodes/parse-bytes.md) diff --git a/src/cheatcodes/README.md b/src/cheatcodes/README.md index 4b57a04db..975ea3294 100644 --- a/src/cheatcodes/README.md +++ b/src/cheatcodes/README.md @@ -204,6 +204,9 @@ interface CheatCodes { // Sets an address' code function etch(address who, bytes calldata code) external; + // Marks a test as skipped. Must be called at the top of the test. + function skip(bool skip) external; + // Expects an error on next call function expectRevert() external; function expectRevert(bytes calldata) external; diff --git a/src/cheatcodes/skip.md b/src/cheatcodes/skip.md new file mode 100644 index 000000000..1428bdf95 --- /dev/null +++ b/src/cheatcodes/skip.md @@ -0,0 +1,32 @@ +## `skip` + +## Signature + +```solidity +function skip(bool skip) external; +``` + +## Description + +Marks a test as skipped, conditionally. It must be called at the top of the test to ensure it is skipped without any execution. + +If `skip` is called with a false boolean, it will not skip the test. + +Tests marked as skipped will appear with a `[SKIPPED]` label on the test runner and on the summary, to easily identify skipped tests. + +### Examples + +```solidity + +function testSkip() public { + cheats.skip(true); + /// This revert will not be reached as this test will be skipped. + revert("Should not reach this revert"); +} + +function testNotSkip() public { + cheats.skip(false); + /// This revert will be reached as this test will not be skipped, and the test will fail. + revert("Should reach this revert"); +} +``` \ No newline at end of file