Sealed test

This crate expose the #[sealed_test] macro attribute to run your test in an isolated environment.

It provides the following : - an isolated process using rusty-fork and - a temporary work dir tempfile.

Caution: using #[sealed_test] instead of #[test] will create a temporary file and set it to be the test current directory but, nothing stops you from changing that directory using std::env::set_current_dir.

Example

Without sealed_test :

The below bar test will fail because the environment variable will be concurrently altered by the foo test.

```rust

[test]

fn foo() -> Result<(), VarError> { std::env::setvar("VAR", "foo"); let var = std::env::var("VAR")?; asserteq!(var, "foo"); Ok(()) }

[test]

fn bar() -> Result<(), VarError> { std::env::setvar("VAR", "bar"); // During the thread sleep, the foo test will run // and set the environment variable to "foo" std::thread::sleep(Duration::fromsecs(1)); let var = std::env::var("VAR")?; // If running tests on multiple threads the below assertion will fail assert_eq!(var, "bar"); Ok(()) } ```

With sealed_test :

Here each test has its own environment, the tests will always pass.

```rust use sealed_test::prelude::*;

[sealed_test]

fn foo() -> Result<(), VarError> { std::env::setvar("VAR", "bar"); let var = std::env::var("VAR")?; asserteq!(var, "bar"); Ok(()) }

[sealed_test]

fn bar() -> Result<(), VarError> { std::env::setvar("VAR", "bar"); std::thread::sleep(Duration::fromsecs(1)); let var = std::env::var("VAR")?; assert_eq!(var, "bar"); Ok(()) } ```