Skip to content

Commit

Permalink
Revert "Test compilation diagnostics reporter (#1577)"
Browse files Browse the repository at this point in the history
This reverts commit 64c9eb6.
  • Loading branch information
maciektr committed Sep 25, 2024
1 parent e256b69 commit be6fec9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
17 changes: 12 additions & 5 deletions scarb/src/compiler/compilers/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use crate::compiler::compilers::{
ensure_gas_enabled, get_compiled_contracts, ArtifactsWriter, CompiledContracts,
ContractSelector,
};
use crate::compiler::helpers::{build_compiler_config, collect_main_crate_ids, write_json};
use crate::compiler::helpers::{
build_compiler_config, collect_all_crate_ids, collect_main_crate_ids, write_json,
};
use crate::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler};
use crate::core::{PackageName, SourceId, TargetKind, TestTargetProps, Workspace};
use crate::flock::Filesystem;
Expand All @@ -37,7 +39,7 @@ impl Compiler for TestCompiler {

let test_crate_ids = collect_main_crate_ids(&unit, db);
// Search for all contracts in deps specified with `build-external-contracts`.
let all_crate_ids =
let main_crate_ids =
get_contract_crate_ids(&build_external_contracts, test_crate_ids.clone(), db);

let starknet = unit.cairo_plugins.iter().any(|plugin| {
Expand All @@ -46,7 +48,11 @@ impl Compiler for TestCompiler {
});

let diagnostics_reporter =
build_compiler_config(db, &unit, &test_crate_ids, ws).diagnostics_reporter;
build_compiler_config(db, &unit, &main_crate_ids, ws).diagnostics_reporter;
let all_crate_ids = collect_all_crate_ids(&unit, db);
diagnostics_reporter
.with_crates(&all_crate_ids)
.ensure(db)?;

let test_compilation = {
let _ = trace_span!("compile_test").enter();
Expand All @@ -59,12 +65,13 @@ impl Compiler for TestCompiler {
.compiler_config
.unstable_add_statements_code_locations_debug_info,
};
let allow_warnings = unit.compiler_config.allow_warnings;
compile_test_prepared_db(
db,
config,
all_crate_ids.clone(),
main_crate_ids,
test_crate_ids.clone(),
diagnostics_reporter,
allow_warnings,
)?
};

Expand Down
7 changes: 7 additions & 0 deletions scarb/src/compiler/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ pub fn collect_main_crate_ids(unit: &CairoCompilationUnit, db: &RootDatabase) ->
))]
}

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()
}

pub fn write_json(
file_name: &str,
description: &str,
Expand Down
6 changes: 0 additions & 6 deletions scarb/tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,12 +958,6 @@ fn does_not_show_warnings_from_deps() {
.current_dir(&second)
.assert()
.success();
Scarb::quick_snapbox()
.arg("build")
.arg("--test")
.current_dir(&second)
.assert()
.success();
}

#[test]
Expand Down

0 comments on commit be6fec9

Please sign in to comment.