Commit graph

16 commits

Author SHA1 Message Date
JasterV
a76038297a chore: update deps 2026-04-23 01:34:39 +02:00
Victor Martinez Montané
dc77d78608 fix/pattern-matching-breaks-compilation (#4)
This PR solves the issue identified at https://codeberg.org/JasterV/test-context/issues/2.

Previously, when defining the function argument that implements the `TestContext` trait, only "Ident" patterns were accepted (That is, only names).

So, the following was valid:

```rust
#[test]
fn my_test(context: MyContext) {}
```

But the following would throw an error:

```rust
#[test]
fn my_test(MyContext { n }: MyContext {}
```

With this PR, we are now able to accept any kind of "pattern" such as struct pattern matching, enum pattern matching... etc.

We only really care about the "type", and not the "pattern", so this PR makes sure that the "pattern" part of the binding is left untouched.

Tests have been added to ensure that destructuring a struct compiles

Co-authored-by: JasterV <49537445+JasterV@users.noreply.github.com>
Reviewed-on: https://codeberg.org/JasterV/test-context/pulls/4
2026-04-22 17:26:08 +02:00
Víctor Martínez
63cb4631a3
chore: internal refactor & update docs (#64) 2025-11-10 11:04:42 +01:00
JasterV
b37885d27c refactor: make arg parsing code more readable 2025-11-06 16:15:31 +01:00
Víctor Martínez
bfe1703448
fix: mut ownership doesn't work (#60) 2025-11-06 14:18:27 +01:00
Víctor Martínez
39756352a8
feat: make it so immutable references & full ownership can be taken depending on context (#58)
This pull requests introduces changes that make the use of the `test_context` macro more flexible.

Now, if the teardown is not skipped (default behavior), either an `immutable` or a `mutable` reference can be used for the context.

If the teardown is skipped with the `skip_teardown` option, an `immutable`, a `mutable` reference or full ownership can be taken.

So now the following is possible:

```rust
#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown(_ctx: &mut TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown_with_immutable_ref(_ctx: &TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[tokio::test]
async fn test_async_skip_teardown_with_full_ownership(_ctx: TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown(_ctx: &mut TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown_with_immutable_ref(_ctx: &TeardownPanicContext) {}

#[test_context(TeardownPanicContext, skip_teardown)]
#[test]
fn test_sync_skip_teardown_with_full_ownership(_ctx: TeardownPanicContext) {}
```
2025-11-06 13:52:20 +01:00
JasterV
5e407cdfa2 chore: update CHANGELOGS 2025-11-04 17:38:55 +01:00
Víctor Martínez
ef4bdb28a9
fix: Regression in version 0.5.0 (#55)
An attempt to fix the issue defined in https://github.com/JasterV/test-context/issues/53 & some refactors
2025-11-04 17:27:53 +01:00
Vyacheslav
9227f3e693
Added the ability to work with rstest (#51)
* [FIX-CONFLICT-WITH-RSTEST-V2]: semi-stable version, fix test_context function, remove unnecessary field, remove wrapper function, add  ability to work with rstest and same

* [FIX-CONFLICT-WITH-RSTEST-V2]: stable version, fix bugs with AssertUnwindSafe in sync_wrapper_body, remove redundant code, fix two tests, add notes for this tests

* [FIX-CONFLICT-WITH-RSTEST-V2]: stable version, fix context name extraction function, fix readme, fix docs, increase version of crate

---------

Co-authored-by: Vyacheslav Volkov <v.volkov@st-falcon.ru>
2025-10-29 10:19:40 +01:00
Changju Lee
a58e13ecf5
feat: Support generic types in test_context macro (#44)
- Allow using test_context with generic contexts like MyContext<T>
2025-01-27 11:53:39 +01:00
Víctor Martínez
dc2992cbff
feat: add support for the skip_teardown keyword (#40)
* feat: add support for the skip_teardown keyword
2024-02-27 23:26:40 +01:00
Victor Martinez
0fed446341 refactor: clean up the macro implementation 2024-02-26 16:03:47 +01:00
Victor Martinez
be1f0e1dbd chore: upgrade to 0.2.0 version 2024-02-26 12:12:38 +01:00
Victor Martinez
cb4043fae6 refactor: remove support for async-trait crate 2024-02-26 12:05:07 +01:00
Victor Martinez
58faeefa63 chore: update workspace properties 2024-02-26 00:27:59 +01:00
Victor Martinez
3539bcdd6d refactor: restructure the workspace members organization 2024-02-26 00:19:53 +01:00