diff --git a/bin/sozo/src/commands/test.rs b/bin/sozo/src/commands/test.rs index 19f8279f18..ff7c11976a 100644 --- a/bin/sozo/src/commands/test.rs +++ b/bin/sozo/src/commands/test.rs @@ -9,7 +9,7 @@ use cairo_lang_starknet::starknet_plugin_suite; use cairo_lang_test_plugin::test_plugin_suite; use cairo_lang_test_runner::{CompiledTestRunner, RunProfilerConfig, TestCompiler, TestRunConfig}; use clap::Args; -use dojo_lang::compiler::{collect_core_crate_ids, collect_external_crate_ids, Props}; +use dojo_lang::compiler::{collect_core_crate_ids, collect_crate_ids, Props}; use dojo_lang::plugin::dojo_plugin_suite; use dojo_lang::scarb_internal::crates_config_for_compilation_unit; use scarb::compiler::helpers::collect_main_crate_ids; @@ -101,7 +101,7 @@ impl TestArgs { } if let Some(external_contracts) = props.build_external_contracts { - main_crate_ids.extend(collect_external_crate_ids(&db, external_contracts)); + main_crate_ids.extend(collect_crate_ids(&db, external_contracts)); } let config = TestRunConfig { diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index 653aab250e..a38eacba3c 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -63,6 +63,7 @@ pub struct DojoCompiler; #[serde(rename_all = "kebab-case")] pub struct Props { pub build_external_contracts: Option>, + pub skip_migration: Option>, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -157,7 +158,14 @@ impl Compiler for DojoCompiler { compiled_classes.insert(contract_full_path.into(), (class_hash, class.abi)); } - update_manifest(db, ws, &main_crate_ids, compiled_classes, props.build_external_contracts)?; + update_manifest( + db, + ws, + &main_crate_ids, + compiled_classes, + props.build_external_contracts, + props.skip_migration, + )?; Ok(()) } } @@ -220,11 +228,8 @@ pub fn collect_core_crate_ids(db: &RootDatabase) -> Vec { .collect::>() } -pub fn collect_external_crate_ids( - db: &RootDatabase, - external_contracts: Vec, -) -> Vec { - external_contracts +pub fn collect_crate_ids(db: &RootDatabase, contracts: Vec) -> Vec { + contracts .iter() .map(|selector| selector.package().into()) .unique() @@ -238,6 +243,7 @@ fn update_manifest( crate_ids: &[CrateId], compiled_artifacts: HashMap)>, external_contracts: Option>, + skip_migration: Option>, ) -> anyhow::Result<()> { let profile_name = ws.current_profile().expect("Scarb profile expected to be defined.").to_string(); @@ -288,10 +294,17 @@ fn update_manifest( let mut computed = BTreeMap::new(); if let Some(external_contracts) = external_contracts { - let external_crate_ids = collect_external_crate_ids(db, external_contracts); + let external_crate_ids = collect_crate_ids(db, external_contracts); crate_ids.extend(external_crate_ids); } + if let Some(skip_contracts) = skip_migration { + let skip_crate_ids = collect_crate_ids(db, skip_contracts); + + // remove crate_ids present in `skip_crate_ids` + crate_ids.retain(|id| !skip_crate_ids.contains(id)) + } + for crate_id in crate_ids { for module_id in db.crate_modules(crate_id).as_ref() { let file_infos = db.module_generated_file_infos(*module_id).unwrap_or_default(); diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 8a1e9613e9..80d8f45c94 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -14,6 +14,7 @@ dojo = { path = "../../crates/dojo-core" } [[target.dojo]] build-external-contracts = [ ] +skip-migration = [ ] [tool.dojo.world] description = "example world"