mitsuhiko / mitsuhiko/insta

allow_duplicates should work for async code too

Open
#369 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3k
Forks
159
Avg merge
7h 17m
Merged PRs (30d)
2

Description

I want to make my tests async so I can easily parallelize them for speed. I also want to use allow_duplicates!. Unfortunately this doesn't work as it uses a non-async helper function, and if I were to have that function return a future then the future wouldn't support duplicates as the code would not be running from within the context of allow_duplicates! anymore.

What I'd like is an allow_duplicates_async! version that acts like an async {} block except allowing duplicates for code running in the future. This could work by returning a custom future that sets up the duplicates infrastructure on each poll (thus still allowing for the use of thread-local state in the implementation).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementations of allow_duplicates! and async {} and the future behavior described in the issue. Determine how duplicate tracking is initialized across future polls; done means an async counterpart permits duplicates for code running in the future without losing the required context.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.