[go: up one dir, main page]

Harness

Struct Harness 

Source
pub struct Harness<S, T, I, E> { /* private fields */ }
Expand description

Harness for discovering test inputs and asserting against snapshot files

Implementations§

Source§

impl<S, T, I, E> Harness<S, T, I, E>
where S: Setup + Send + Sync + 'static, T: Test<I, E> + Clone + Send + Sync + 'static, I: Display, E: Display,

Source

pub fn new(input_root: impl Into<PathBuf>, setup: S, test: T) -> Self

Specify where the test scenarios

  • input_root: where to find the files. See Self::select for restricting what files are considered
  • setup: Given a path, choose the test name and the output location
  • test: Given a path, return the actual output value

By default filters are applied, including:

  • ... is a line-wildcard when on a line by itself
  • [..] is a character-wildcard when inside a line
  • [EXE] matches .exe on Windows
  • "{...}" is a JSON value wildcard
  • "...": "{...}" is a JSON key-value wildcard
  • \ to /
  • Newlines

To limit this to newline normalization for text, have Setup call Data::raw on expected.

Source

pub fn select<'p>(self, patterns: impl IntoIterator<Item = &'p str>) -> Self

Path patterns for selecting input files

This uses gitignore syntax

Source

pub fn with_assert(self, config: Assert) -> Self

Customize the assertion behavior

Includes

  • Configuring redactions
  • Override updating environment vaeiable
Source

pub fn test(self) -> !

Run tests

Auto Trait Implementations§

§

impl<S, T, I, E> Freeze for Harness<S, T, I, E>
where S: Freeze, T: Freeze,

§

impl<S, T, I, E> RefUnwindSafe for Harness<S, T, I, E>

§

impl<S, T, I, E> Send for Harness<S, T, I, E>
where S: Send, T: Send, I: Send, E: Send,

§

impl<S, T, I, E> Sync for Harness<S, T, I, E>
where S: Sync, T: Sync, I: Sync, E: Sync,

§

impl<S, T, I, E> Unpin for Harness<S, T, I, E>
where S: Unpin, T: Unpin, I: Unpin, E: Unpin,

§

impl<S, T, I, E> UnwindSafe for Harness<S, T, I, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.