From f302121adbd321e74996b3f3db56f66079b19380 Mon Sep 17 00:00:00 2001 From: Enrique Ortiz Date: Wed, 28 Jun 2023 11:37:42 -0400 Subject: [PATCH] feat: add skip cheatcode docs --- 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