diff --git a/README.md b/README.md index d0ecf7a..87b51e3 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,13 @@ Pass tests are considered to succeed if they compile successfully and have a That's the entire API. +### Conditional compilation + +Trybuild sets `cfg(trybuild)` when compiling test cases. In a test case, +use `#[cfg(trybuild)]` to include code in these compilations, or +`#[cfg(not(trybuild))]` to exclude it. Trybuild does not set this cfg for +the outer test harness that calls `TestCases`. +
## Workflow diff --git a/src/lib.rs b/src/lib.rs index c6d06d0..05ed62d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,6 +105,13 @@ //! //! That's the entire API. //! +//! ## Conditional compilation +//! +//! Trybuild sets `cfg(trybuild)` when compiling test cases. In a test case, +//! use `#[cfg(trybuild)]` to include code in these compilations, or +//! `#[cfg(not(trybuild))]` to exclude it. Trybuild does not set this cfg for +//! the outer test harness that calls `TestCases`. +//! //!
//! //! # Workflow