Have an __setup__ function being run before each test
tdelabro opened this issue · 3 comments
If a .cairo file contains a function named __setup__
, execute it before executing the test.
Ideas on how to implement it:
Add a before_first_step
hook in the VM, in run_until_pc
, that will push a call to setup by storing current fp
and pc
in memory and moving pc
to the address of __setup__
(simulating a call
).
Note: this won't be useful until we have starknet integration in cairo-rs
We aim to create a DX-friendly testing experience. To achieve that, we'll need to access important moments of the execution process.
Namely, we'd like to have these known test utils: beforeAll, afterAll, beforeEach ( ✅ we have this pre_step_instruction), afterEach
The before_run hook would be the equivalent of beforeAll and similar hooks. It would run at the very beginning of your process (per test function, i.e. per run). It does not need to execute hints (such as mocking etc.) just yet.
The aim of this issue is to invest brain power in proposing a sound strategy to properly hook into this particular step of the execution process.
Naming between before_first_step
and before_run
is up for debate:)!
We just need something consistent
After assessment, before_run
and before_first_step
are not exactly the same! Let's start with before_first_step