pub async fn run_with_harness<H, F, Fut>(test_func: F) -> Result<(), Error>
where
    H: TestHarness,
    F: FnOnce(H) -> Fut + Send + 'static,
    Fut: Future<Output = Result<(), Error>> + Send + 'static,
{
    let (harness, env, runner) = H::init().await.context("Error initializing harness")?;

    let run_test = test_func(harness);
    pin_mut!(run_test);
    pin_mut!(runner);

    let result = select! {
        test_result = run_test.fuse() => test_result,
        runner_result = runner.fuse() => runner_result.context("Error running harness background task"),
    };

    let term_result = H::terminate(env).await.context("Error terminating harness");
    // Return test failure if it exists, else return terminate failure, else return the
    // successful test result
    result.and_then(|ok| term_result.map(|_| ok))
}
/// We can run any test which is an async function from some harness `H` to a result
We can run any test which is an async function from some harness `H` to a result
We can run any test which is an async function from some harness ` H ` to a result
pub async fn run_with_harness<H, F, Fut>(test_func: F) -> Result<(), Error>
where
    H: TestHarness,
    F: FnOnce(H) -> Fut + Send + 'static,
    Fut: Future<Output = Result<(), Error>> + Send + 'static,
{
    let (harness, env, runner) = H::init().await.context("Error initializing harness")?;
    let run_test = test_func(harness);
    pin_mut!(run_test);
    pin_mut!(runner);
    let result = select! {
        test_result = run_test.fuse() => test_result,
        runner_result = runner.fuse() => runner_result.context("Error running harness background task"),
    };
    let term_result = H::terminate(env).await.context("Error terminating harness");
    // Return test failure if it exists, else return terminate failure, else return the
    // successful test result
    result.and_then(|ok| term_result.map(|_| ok))
}
pub async fn run_with_harness < H , F , Fut > ( test_func : F ) -> Result < ( ) , Error > where H : TestHarness , F : FnOnce ( H ) -> Fut + Send + ' static , Fut : Future < Output = Result < ( ) , Error > > + Send + ' static , { let ( harness , env , runner ) = H :: init ( ) . await . context ( " " ) ? ; let run_test = test_func ( harness ) ; pin_mut ! ( run_test ) ; pin_mut ! ( runner ) ; let result = select ! { test_result run_test fuse ( ) test_result runner_result runner fuse ( ) runner_result context ( " " ) } ; let term_result = H :: terminate ( env ) . await . context ( " " ) ; // Return test failure if it exists, else return terminate failure, else return the // successful test result result . and_then ( | ok | term_result . map ( | _ | ok ) ) }
We can run any test which is an async function from some harness `H` to a result
We can run any test which is an async function from some harness ` H ` to a result
test_func
F
test_func
F