Skip to content

Commit

Permalink
fix: ensure all crates are present when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 12, 2024
1 parent 2c79b85 commit afd1b87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bins/demo-compiler/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use cairo_lang_test_plugin::{test_plugin_suite, TestsCompilationConfig};
use cairo_lang_test_runner::{CompiledTestRunner, RunProfilerConfig, TestCompiler, TestRunConfig};
use clap::Args;
use dojo_compiler::compiler::cairo_compiler::{
collect_crates_ids_from_selectors, collect_main_crate_ids, Props,
collect_all_crate_ids, collect_crates_ids_from_selectors, collect_main_crate_ids, Props,
};
use dojo_compiler::compiler::config::{CompilerConfig, DojoConfigLoader};
use dojo_compiler::compiler::scarb_internal::{
Expand Down Expand Up @@ -165,7 +165,7 @@ impl TestArgs {

let test_crate_ids = collect_main_crate_ids(&unit, &db, false);

let mut main_crate_ids = test_crate_ids.clone();
let mut main_crate_ids = collect_all_crate_ids(&unit, &db);

if let Some(external_contracts) = props.build_external_contracts {
main_crate_ids.extend(collect_crates_ids_from_selectors(&db, &external_contracts));
Expand Down
7 changes: 7 additions & 0 deletions crates/compiler/src/compiler/cairo_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,10 @@ pub fn collect_crates_ids_from_selectors(
.map(|package_name: SmolStr| db.intern_crate(CrateLongId::Real(package_name)))
.collect::<Vec<_>>()
}

pub fn collect_all_crate_ids(unit: &CairoCompilationUnit, db: &RootDatabase) -> Vec<CrateId> {
unit.components
.iter()
.map(|component| db.intern_crate(CrateLongId::Real(component.cairo_package_name())))
.collect()
}

0 comments on commit afd1b87

Please sign in to comment.