Skip to content

Commit e27ad22

Browse files
Move test utils to testing module (#1422)
* move testing utils to testing module * make the module available only when testing or with testing feature * export macros * move tests to their correct module * fmt --------- Co-authored-by: gabrielbosio <[email protected]>
1 parent a27b556 commit e27ad22

35 files changed

+258
-284
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ with-mem-tracing = []
115115
with-libfunc-profiling = []
116116
with-segfault-catcher = []
117117
with-trace-dump = ["dep:sierra-emu"]
118-
testing = ["dep:cairo-lang-compiler"]
118+
testing = ["dep:cairo-lang-compiler", "dep:cairo-lang-starknet", "dep:cairo-lang-filesystem"]
119119

120120
[dependencies]
121121
aquamarine.workspace = true
122122
bumpalo.workspace = true
123123
cairo-lang-compiler = { workspace = true, optional = true }
124+
cairo-lang-filesystem = { workspace = true, optional = true }
125+
cairo-lang-starknet = { workspace = true, optional = true }
124126
cairo-lang-runner.workspace = true
125127
cairo-lang-sierra.workspace = true
126128
cairo-lang-utils.workspace = true

src/cache/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ where
8787
#[cfg(test)]
8888
mod tests {
8989
use super::*;
90-
use crate::{utils::test::load_cairo, values::Value};
90+
use crate::{load_cairo, values::Value};
9191
use starknet_types_core::felt::Felt;
9292

9393
#[test]

src/cache/jit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ where
7070
#[cfg(test)]
7171
mod test {
7272
use super::*;
73-
use crate::utils::test::load_cairo;
73+
use crate::load_cairo;
7474
use std::time::Instant;
7575

7676
#[test]

src/executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ fn parse_result(
686686
mod tests {
687687
use super::*;
688688
use crate::{
689-
context::NativeContext, starknet_stub::StubSyscallHandler, utils::test::load_cairo,
690-
utils::test::load_starknet, OptLevel,
689+
context::NativeContext, load_cairo, load_starknet, starknet_stub::StubSyscallHandler,
690+
OptLevel,
691691
};
692692
use cairo_lang_sierra::program::Program;
693693
use rstest::*;

src/executor/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ mod tests {
205205
use crate::{
206206
context::NativeContext,
207207
starknet_stub::StubSyscallHandler,
208-
utils::test::{load_cairo, load_starknet},
208+
{load_cairo, load_starknet},
209209
};
210210
use cairo_lang_sierra::program::Program;
211211
use rstest::*;

src/executor/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ impl Drop for LockFile {
814814
#[cfg(test)]
815815
mod tests {
816816
use super::*;
817-
use crate::{starknet_stub::StubSyscallHandler, utils::test::load_starknet_contract};
817+
use crate::{load_starknet_contract, starknet_stub::StubSyscallHandler};
818818
use cairo_lang_starknet_classes::contract_class::{
819819
version_id_from_serialized_sierra_program, ContractClass,
820820
};

src/libfuncs/array.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,10 +1303,8 @@ fn is_shared<'ctx, 'this>(
13031303
#[cfg(test)]
13041304
mod test {
13051305
use crate::{
1306-
utils::{
1307-
felt252_str,
1308-
test::{jit_enum, jit_panic, jit_struct, load_cairo, run_program},
1309-
},
1306+
jit_enum, jit_panic, jit_struct, load_cairo,
1307+
utils::{felt252_str, testing::run_program},
13101308
values::Value,
13111309
};
13121310
use pretty_assertions_sorted::assert_eq;

src/libfuncs/bool.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,7 @@ pub fn build_bool_to_felt252<'ctx, 'this>(
207207

208208
#[cfg(test)]
209209
mod test {
210-
use crate::{
211-
utils::test::{jit_enum, jit_struct, load_cairo, run_program},
212-
values::Value,
213-
};
210+
use crate::{jit_enum, jit_struct, load_cairo, utils::testing::run_program, values::Value};
214211

215212
#[test]
216213
fn run_not() {

src/libfuncs/bounded_int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ mod test {
855855

856856
use crate::{
857857
context::NativeContext, execution_result::ExecutionResult, executor::JitNativeExecutor,
858-
utils::test::load_cairo, OptLevel, Value,
858+
load_cairo, OptLevel, Value,
859859
};
860860

861861
#[test]

src/libfuncs/box.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,7 @@ pub fn build_unbox<'ctx, 'this>(
151151

152152
#[cfg(test)]
153153
mod test {
154-
use crate::{
155-
utils::test::{load_cairo, run_program_assert_output},
156-
values::Value,
157-
};
154+
use crate::{load_cairo, utils::testing::run_program_assert_output, values::Value};
158155

159156
#[test]
160157
fn run_box_unbox() {

0 commit comments

Comments
 (0)