From b55561130f9882c2de8a016856285e200099862d Mon Sep 17 00:00:00 2001 From: maciektr Date: Thu, 13 Jun 2024 14:48:44 +0200 Subject: [PATCH] Require explicit dependence on `cairo_test` (i.e. `test_plugin`)" commit-id:83a53c59 --- examples/dependencies/Scarb.toml | 3 + examples/hello_world/Scarb.toml | 3 + examples/starknet_hello_world/Scarb.toml | 3 + .../starknet_multiple_contracts/Scarb.toml | 3 + examples/workspaces/Scarb.toml | 4 ++ .../workspaces/crates/addition/Scarb.toml | 3 + .../workspaces/crates/fibonacci/Scarb.toml | 3 + extensions/scarb-cairo-test/tests/build.rs | 4 ++ scarb/src/core/manifest/summary.rs | 22 +------ scarb/src/core/manifest/toml_manifest.rs | 1 - scarb/src/core/registry/mod.rs | 5 +- scarb/src/ops/resolve.rs | 23 ++++++- scarb/src/resolver/mod.rs | 16 +---- scarb/src/sources/registry.rs | 4 +- scarb/tests/build_targets.rs | 2 + scarb/tests/expand.rs | 3 + scarb/tests/git_source.rs | 3 + scarb/tests/metadata.rs | 62 +++++++++++++++---- scarb/tests/profiles.rs | 1 + .../scarb-test-support/src/project_builder.rs | 4 ++ 20 files changed, 114 insertions(+), 58 deletions(-) diff --git a/examples/dependencies/Scarb.toml b/examples/dependencies/Scarb.toml index 0a97c0499..5547905ed 100644 --- a/examples/dependencies/Scarb.toml +++ b/examples/dependencies/Scarb.toml @@ -6,3 +6,6 @@ version = "0.1.0" [dependencies] alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" } + +[dev-dependencies] +cairo_test = "2.6.0" diff --git a/examples/hello_world/Scarb.toml b/examples/hello_world/Scarb.toml index 4a2e55dce..a112d511d 100644 --- a/examples/hello_world/Scarb.toml +++ b/examples/hello_world/Scarb.toml @@ -6,3 +6,6 @@ edition = "2023_10" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html [dependencies] + +[dev-dependencies] +cairo_test = "2.6.0" diff --git a/examples/starknet_hello_world/Scarb.toml b/examples/starknet_hello_world/Scarb.toml index d9b418780..25f986a66 100644 --- a/examples/starknet_hello_world/Scarb.toml +++ b/examples/starknet_hello_world/Scarb.toml @@ -7,4 +7,7 @@ version = "0.1.0" [dependencies] starknet = "2.6.0" +[dev-dependencies] +cairo_test = "2.6.0" + [[target.starknet-contract]] diff --git a/examples/starknet_multiple_contracts/Scarb.toml b/examples/starknet_multiple_contracts/Scarb.toml index 34a0f2cad..9313b626e 100644 --- a/examples/starknet_multiple_contracts/Scarb.toml +++ b/examples/starknet_multiple_contracts/Scarb.toml @@ -7,4 +7,7 @@ version = "0.1.0" [dependencies] starknet = "2.6.0" +[dev-dependencies] +cairo_test = "2.6.0" + [[target.starknet-contract]] diff --git a/examples/workspaces/Scarb.toml b/examples/workspaces/Scarb.toml index 0ffdb07c2..940787aa5 100644 --- a/examples/workspaces/Scarb.toml +++ b/examples/workspaces/Scarb.toml @@ -10,6 +10,7 @@ test = "snforge" exit_first = true [workspace.dependencies] +cairo_test = "2.6.0" starknet = "2.6.0" [workspace.package] @@ -30,4 +31,7 @@ starknet.workspace = true fibonacci = { path = "crates/fibonacci" } addition = { path = "crates/addition" } +[dev-dependencies] +cairo_test.workspace = true + [[target.starknet-contract]] diff --git a/examples/workspaces/crates/addition/Scarb.toml b/examples/workspaces/crates/addition/Scarb.toml index a1c32b8dc..620b85585 100644 --- a/examples/workspaces/crates/addition/Scarb.toml +++ b/examples/workspaces/crates/addition/Scarb.toml @@ -3,3 +3,6 @@ name = "addition" version.workspace = true [lib] + +[dev-dependencies] +cairo_test.workspace = true diff --git a/examples/workspaces/crates/fibonacci/Scarb.toml b/examples/workspaces/crates/fibonacci/Scarb.toml index 5720e6d60..10e51a51d 100644 --- a/examples/workspaces/crates/fibonacci/Scarb.toml +++ b/examples/workspaces/crates/fibonacci/Scarb.toml @@ -10,3 +10,6 @@ snforge.workspace = true [dependencies] addition = { path = "../addition" } + +[dev-dependencies] +cairo_test.workspace = true diff --git a/extensions/scarb-cairo-test/tests/build.rs b/extensions/scarb-cairo-test/tests/build.rs index 89854fa1e..092c3e02d 100644 --- a/extensions/scarb-cairo-test/tests/build.rs +++ b/extensions/scarb-cairo-test/tests/build.rs @@ -33,6 +33,7 @@ fn can_test_without_gas() { } } "#}) + .dep_cairo_test() .manifest_extra(indoc! {r#" [cairo] enable-gas = false @@ -86,6 +87,7 @@ fn can_print_test_resources() { } } "#}) + .dep_cairo_test() .build(&t); Scarb::quick_snapbox() .arg("cairo-test") @@ -130,6 +132,7 @@ fn get_features_test_build(t: &TempDir) { } } "#}) + .dep_cairo_test() .build(t); } @@ -219,6 +222,7 @@ fn integration_tests() { {test_case} "#}) + .dep_cairo_test() .src("tests/a.cairo", test_case) .src("tests/b.cairo", test_case) .build(&t); diff --git a/scarb/src/core/manifest/summary.rs b/scarb/src/core/manifest/summary.rs index 111819295..abb876f21 100644 --- a/scarb/src/core/manifest/summary.rs +++ b/scarb/src/core/manifest/summary.rs @@ -1,4 +1,3 @@ -use std::collections::HashSet; use std::ops::Deref; use std::sync::Arc; @@ -8,8 +7,7 @@ use typed_builder::TypedBuilder; #[cfg(doc)] use crate::core::Manifest; use crate::core::{ - Checksum, DepKind, DependencyVersionReq, ManifestDependency, PackageId, PackageName, SourceId, - TargetKind, + Checksum, DepKind, DependencyVersionReq, ManifestDependency, PackageId, PackageName, }; /// Subset of a [`Manifest`] that contains only the most important information about a package. @@ -27,7 +25,6 @@ pub struct SummaryInner { pub package_id: PackageId, #[builder(default)] pub dependencies: Vec, - pub target_kinds: HashSet, #[builder(default = false)] pub no_core: bool, #[builder(default)] @@ -79,27 +76,10 @@ impl Summary { .version_req(DependencyVersionReq::exact(&cairo_version)) .build() }); - - static TEST_PLUGIN_DEPENDENCY: Lazy = Lazy::new(|| { - // NOTE: Pin test plugin to exact version, because we know that's the only one we have. - let cairo_version = crate::version::get().cairo.version.parse().unwrap(); - ManifestDependency::builder() - .kind(DepKind::Target(TargetKind::TEST)) - .name(PackageName::TEST_PLUGIN) - .source_id(SourceId::default()) - .version_req(DependencyVersionReq::exact(&cairo_version)) - .build() - }); - let mut deps: Vec<&ManifestDependency> = Vec::new(); - if !self.no_core { deps.push(&CORE_DEPENDENCY); } - if self.target_kinds.contains(&TargetKind::TEST) { - deps.push(&TEST_PLUGIN_DEPENDENCY); - } - deps.into_iter() } diff --git a/scarb/src/core/manifest/toml_manifest.rs b/scarb/src/core/manifest/toml_manifest.rs index 075e20299..48f4e383b 100644 --- a/scarb/src/core/manifest/toml_manifest.rs +++ b/scarb/src/core/manifest/toml_manifest.rs @@ -454,7 +454,6 @@ impl TomlManifest { let targets = self.collect_targets(package.name.to_smol_str(), root)?; let summary = Summary::builder() - .target_kinds(targets.iter().map(|t| t.kind.clone()).collect()) .package_id(package_id) .dependencies(dependencies) .no_core(no_core) diff --git a/scarb/src/core/registry/mod.rs b/scarb/src/core/registry/mod.rs index cbf41a3ba..dc1a235f0 100644 --- a/scarb/src/core/registry/mod.rs +++ b/scarb/src/core/registry/mod.rs @@ -34,9 +34,7 @@ pub(crate) mod mock { use crate::core::package::PackageName; use crate::core::registry::Registry; - use crate::core::{ - ManifestBuilder, ManifestDependency, Package, PackageId, SourceId, Summary, TargetKind, - }; + use crate::core::{ManifestBuilder, ManifestDependency, Package, PackageId, SourceId, Summary}; #[derive(Debug, Default)] pub struct MockRegistry { @@ -111,7 +109,6 @@ pub(crate) mod mock { fn build_package(package_id: PackageId, dependencies: Vec) -> Package { let summary = Summary::builder() - .target_kinds(HashSet::from_iter(vec![TargetKind::LIB])) .package_id(package_id) .dependencies(dependencies) .no_core(package_id.is_core()) diff --git a/scarb/src/ops/resolve.rs b/scarb/src/ops/resolve.rs index e780a3174..412a2aaf7 100644 --- a/scarb/src/ops/resolve.rs +++ b/scarb/src/ops/resolve.rs @@ -117,8 +117,7 @@ pub fn resolve_workspace_with_opts( read_lockfile(ws)? }; - let resolve = - resolver::resolve(&members_summaries, &patched, lockfile, ws.config().ui()).await?; + let resolve = resolver::resolve(&members_summaries, &patched, lockfile).await?; write_lockfile(Lockfile::from_resolve(&resolve), ws)?; @@ -242,6 +241,7 @@ fn generate_cairo_compilation_units( .into_iter() .chain(grouped) .collect(); + solution.show_warnings(); Ok(result) } @@ -433,6 +433,7 @@ pub struct PackageSolutionCollector<'a> { packages: Option>, cairo_plugins: Option>, target_kind: Option, + warnings: HashSet, } impl<'a> PackageSolutionCollector<'a> { @@ -444,6 +445,7 @@ impl<'a> PackageSolutionCollector<'a> { packages: None, cairo_plugins: None, target_kind: None, + warnings: HashSet::new(), } } @@ -464,7 +466,7 @@ impl<'a> PackageSolutionCollector<'a> { } fn pull_from_graph( - &self, + &mut self, target_kind: &TargetKind, ) -> Result<(Vec, Vec)> { let mut classes = self @@ -504,6 +506,15 @@ impl<'a> PackageSolutionCollector<'a> { check_cairo_version_compatibility(&packages, self.ws)?; + // Print warnings for dependencies that are not usable. + let other = classes.remove(&PackageClass::Other).unwrap_or_default(); + for pkg in other { + self.warnings.insert(format!( + "{} ignoring invalid dependency `{}` which is missing a lib or cairo-plugin target", + self.member.id, pkg.id.name + )); + } + let cairo_plugins = cairo_plugins .into_iter() .map(|package| { @@ -519,6 +530,12 @@ impl<'a> PackageSolutionCollector<'a> { Ok((packages, cairo_plugins)) } + + pub fn show_warnings(self) { + for warning in self.warnings { + self.ws.config().ui().warn(warning); + } + } } /// Build a set of `cfg` items to enable while building the compilation unit. diff --git a/scarb/src/resolver/mod.rs b/scarb/src/resolver/mod.rs index 9439624a1..927174770 100644 --- a/scarb/src/resolver/mod.rs +++ b/scarb/src/resolver/mod.rs @@ -3,7 +3,6 @@ use std::collections::HashMap; use anyhow::{bail, Result}; use indoc::{formatdoc, indoc}; use petgraph::graphmap::DiGraphMap; -use scarb_ui::Ui; use std::collections::HashSet; use crate::core::lockfile::Lockfile; @@ -38,7 +37,6 @@ pub async fn resolve( summaries: &[Summary], registry: &dyn Registry, lockfile: Lockfile, - ui: Ui, ) -> Result { // TODO(#2): This is very bad, use PubGrub here. let mut graph = DiGraphMap::::new(); @@ -90,15 +88,6 @@ pub async fn resolve( }; let dep = dep_summary.package_id; - if !(dep_summary.target_kinds.contains(&TargetKind::CAIRO_PLUGIN) - || dep_summary.target_kinds.contains(&TargetKind::LIB)) - { - ui.warn(format!( - "{} ignoring invalid dependency `{}` which is missing a lib or cairo-plugin target", - package_id, dep.name - )); - } - if let Some(existing) = packages.get(dep.name.as_ref()) { if existing.source_id != dep.source_id { bail!( @@ -215,8 +204,6 @@ mod tests { use anyhow::Result; use indoc::indoc; use itertools::Itertools; - use scarb_ui::Verbosity::Verbose; - use scarb_ui::{OutputFormat, Ui}; use semver::Version; use similar_asserts::assert_serde_eq; use tokio::runtime::Builder; @@ -300,8 +287,7 @@ mod tests { .collect_vec(); let lockfile = Lockfile::new(locks.iter().cloned()); - let ui = Ui::new(Verbose, OutputFormat::Text); - runtime.block_on(super::resolve(&summaries, ®istry, lockfile, ui)) + runtime.block_on(super::resolve(&summaries, ®istry, lockfile)) } fn package_id>(name: S) -> PackageId { diff --git a/scarb/src/sources/registry.rs b/scarb/src/sources/registry.rs index 25486e0fa..a872d138c 100644 --- a/scarb/src/sources/registry.rs +++ b/scarb/src/sources/registry.rs @@ -1,4 +1,3 @@ -use std::collections::HashSet; use std::fmt; use anyhow::{anyhow, bail, Context, Result}; @@ -16,7 +15,7 @@ use crate::core::registry::package_source_store::PackageSourceStore; use crate::core::source::Source; use crate::core::{ Checksum, Config, DependencyVersionReq, ManifestDependency, Package, PackageId, SourceId, - Summary, TargetKind, + Summary, }; use crate::flock::FileLockGuard; use crate::sources::PathSource; @@ -105,7 +104,6 @@ impl<'c> Source for RegistrySource<'c> { Summary::builder() .package_id(package_id) .dependencies(dependencies) - .target_kinds(HashSet::from_iter([TargetKind::LIB])) .no_core(record.no_core) .checksum(Some(record.checksum.clone())) .build() diff --git a/scarb/tests/build_targets.rs b/scarb/tests/build_targets.rs index ff6d13513..6368eaf35 100644 --- a/scarb/tests/build_targets.rs +++ b/scarb/tests/build_targets.rs @@ -309,6 +309,7 @@ fn compile_test_target() { let t = TempDir::new().unwrap(); ProjectBuilder::start() .name("hello") + .dep_cairo_test() .lib_cairo(r#"fn f() -> felt252 { 42 }"#) .build(&t); t.child("tests").create_dir_all().unwrap(); @@ -365,6 +366,7 @@ fn integration_tests_do_not_enable_cfg_in_main_package() { let t = TempDir::new().unwrap(); ProjectBuilder::start() .name("hello") + .dep_cairo_test() .lib_cairo(indoc! {r#" #[cfg(test)] fn f() -> felt252 { 42 } diff --git a/scarb/tests/expand.rs b/scarb/tests/expand.rs index 769c47149..56d3ffd5e 100644 --- a/scarb/tests/expand.rs +++ b/scarb/tests/expand.rs @@ -56,6 +56,7 @@ fn expand_integration_test() { "#}; ProjectBuilder::start() .name("hello") + .dep_cairo_test() .lib_cairo(formatdoc! {r#" fn fib(mut n: u32) -> u32 {{ let mut a: u32 = 0; @@ -112,6 +113,7 @@ fn can_select_target_by_kind() { let t = TempDir::new().unwrap(); ProjectBuilder::start() .name("hello") + .dep_cairo_test() .lib_cairo(indoc! {r#" fn hello() -> felt252 { 42 @@ -179,6 +181,7 @@ fn can_expand_multiple_targets() { "#}; ProjectBuilder::start() .name("hello") + .dep_cairo_test() .lib_cairo(formatdoc! {r#" fn fib(mut n: u32) -> u32 {{ let mut a: u32 = 0; diff --git a/scarb/tests/git_source.rs b/scarb/tests/git_source.rs index 890d0ef47..3289339a0 100644 --- a/scarb/tests/git_source.rs +++ b/scarb/tests/git_source.rs @@ -423,10 +423,12 @@ fn transitive_path_dep() { let git_dep = gitx::new("dep1", |t| { ProjectBuilder::start() .name("dep0") + .dep_cairo_test() .lib_cairo("fn hello() -> felt252 { 42 }") .build(&t.child("zero")); ProjectBuilder::start() .name("dep1") + .dep_cairo_test() .lib_cairo("fn hello() -> felt252 { dep0::hello() }") .dep("dep0", Dep.path("../zero")) .build(&t.child("one")); @@ -436,6 +438,7 @@ fn transitive_path_dep() { ProjectBuilder::start() .name("hello") .version("1.0.0") + .dep_cairo_test() .dep("dep0", &git_dep) .dep("dep1", &git_dep) .lib_cairo("fn world() -> felt252 { dep1::hello() }") diff --git a/scarb/tests/metadata.rs b/scarb/tests/metadata.rs index 181c67f26..505254065 100644 --- a/scarb/tests/metadata.rs +++ b/scarb/tests/metadata.rs @@ -104,12 +104,14 @@ fn create_local_dependencies_setup(t: &assert_fs::TempDir) { .name("q") .version("1.0.0") .lib_cairo(r"fn f() -> felt252 { 42 }") + .dep_cairo_test() .build(&t.child("q")); ProjectBuilder::start() .name("z") .version("1.0.0") .lib_cairo(r"fn f() -> felt252 { q::f() }") + .dep_cairo_test() .dep("q", Dep.path("../q")) .build(&t.child("z")); @@ -117,6 +119,7 @@ fn create_local_dependencies_setup(t: &assert_fs::TempDir) { .name("y") .version("1.0.0") .lib_cairo(r"fn f() -> felt252 { z::f() }") + .dep_cairo_test() .dep("z", Dep.path("../z")) .dep("q", Dep.path("../q")) .build(&t.child("y")); @@ -125,6 +128,7 @@ fn create_local_dependencies_setup(t: &assert_fs::TempDir) { .name("x") .version("1.0.0") .lib_cairo(r"fn f() -> felt252 { y::f() }") + .dep_cairo_test() .dep("y", Dep.path("y")) .build(t); } @@ -143,7 +147,9 @@ fn local_dependencies() { assert_eq!( packages_and_deps(meta), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "q".to_string(), @@ -182,10 +188,11 @@ fn local_dependencies() { fn dev_dependencies() { let t = assert_fs::TempDir::new().unwrap(); let q = t.child("q"); - ProjectBuilder::start().name("q").build(&q); + ProjectBuilder::start().name("q").dep_cairo_test().build(&q); ProjectBuilder::start() .name("x") .dep("q", Dep.path("./q")) + .dep_cairo_test() .dev_dep("q", Dep.path("./q")) .build(&t); let meta = Scarb::quick_snapbox() @@ -198,7 +205,9 @@ fn dev_dependencies() { assert_eq!( packages_and_deps(meta.clone()), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "x".to_string(), @@ -239,17 +248,22 @@ fn dev_deps_are_not_propagated() { let t = assert_fs::TempDir::new().unwrap(); let dep1 = t.child("dep1"); - ProjectBuilder::start().name("dep1").build(&dep1); + ProjectBuilder::start() + .name("dep1") + .dep_cairo_test() + .build(&dep1); let dep2 = t.child("dep2"); ProjectBuilder::start() .name("dep2") + .dep_cairo_test() .dev_dep("dep1", &dep1) .build(&dep2); let pkg = t.child("pkg"); ProjectBuilder::start() .name("x") + .dep_cairo_test() .dev_dep("dep2", &dep2) .build(&pkg); @@ -264,7 +278,9 @@ fn dev_deps_are_not_propagated() { assert_eq!( packages_and_deps(metadata.clone()), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "x".to_string(), @@ -506,11 +522,13 @@ fn workspace_simple() { let pkg1 = t.child("first"); ProjectBuilder::start() .name("first") + .dep_cairo_test() .manifest_extra("[[test]]") .build(&pkg1); let pkg2 = t.child("second"); ProjectBuilder::start() .name("second") + .dep_cairo_test() .manifest_extra("[[test]]") // Check paths are relative to manifest file. .dep("first", Dep.path("../first")) @@ -528,7 +546,9 @@ fn workspace_simple() { assert_eq!( packages_and_deps(metadata), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "first".to_string(), @@ -550,14 +570,19 @@ fn workspace_simple() { fn workspace_with_root() { let t = assert_fs::TempDir::new().unwrap().child("test_workspace"); let pkg1 = t.child("first"); - ProjectBuilder::start().name("first").build(&pkg1); + ProjectBuilder::start() + .name("first") + .dep_cairo_test() + .build(&pkg1); let pkg2 = t.child("second"); ProjectBuilder::start() .name("second") + .dep_cairo_test() .dep("first", Dep.path("../first")) .build(&pkg2); let root = ProjectBuilder::start() .name("some_root") + .dep_cairo_test() .dep("first", Dep.path("./first")) .dep("second", Dep.path("./second")); WorkspaceBuilder::start() @@ -574,7 +599,9 @@ fn workspace_with_root() { assert_eq!( packages_and_deps(metadata), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ( "some_root".to_string(), vec![ @@ -608,11 +635,13 @@ fn workspace_as_dep() { let pkg1 = first_t.child("first"); ProjectBuilder::start() .name("first") + .dep_cairo_test() .manifest_extra("[[test]]") .build(&pkg1); let pkg2 = first_t.child("second"); ProjectBuilder::start() .name("second") + .dep_cairo_test() .manifest_extra("[[test]]") .dep("first", Dep.path("../first")) .build(&pkg2); @@ -629,7 +658,9 @@ fn workspace_as_dep() { assert_eq!( packages_and_deps(metadata), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "first".to_string(), @@ -651,6 +682,7 @@ fn workspace_as_dep() { ProjectBuilder::start() .name("third") .manifest_extra("[[test]]") + .dep_cairo_test() .dep("first", Dep.path("../../first_workspace")) .dep("second", Dep.path("../../first_workspace")) .build(&pkg1); @@ -658,6 +690,7 @@ fn workspace_as_dep() { ProjectBuilder::start() .name("fourth") .manifest_extra("[[test]]") + .dep_cairo_test() .dep("third", Dep.path("../third")) .build(&pkg2); WorkspaceBuilder::start() @@ -673,7 +706,9 @@ fn workspace_as_dep() { assert_eq!( packages_and_deps(metadata), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "first".to_string(), @@ -715,6 +750,7 @@ fn workspace_package_key_inheritance() { let some_dep = t.child("some_dep"); ProjectBuilder::start() .name("some_dep") + .dep_cairo_test() .manifest_extra("[[test]]") .version("0.1.0") .build(&some_dep); @@ -723,12 +759,14 @@ fn workspace_package_key_inheritance() { let pkg1 = some_workspace.child("first"); ProjectBuilder::start() .name("first") + .dep_cairo_test() .manifest_extra("[[test]]") .dep("some_dep", Dep.workspace()) .build(&pkg1); let pkg2 = some_workspace.child("second"); ProjectBuilder::start() .name("second") + .dep_cairo_test() .manifest_extra("[[test]]") .dep("first", Dep.path("../first")) .build(&pkg2); @@ -747,7 +785,9 @@ fn workspace_package_key_inheritance() { assert_eq!( packages_and_deps(metadata), BTreeMap::from_iter([ - ("core".to_string(), vec!["cairo_test".to_string()]), + // TODO(maciektr): Update corelib manifest to include cairo_test dep. + // ("core".to_string(), vec!["cairo_test".to_string()]), + ("core".to_string(), vec![]), ("cairo_test".to_string(), vec![]), ( "first".to_string(), diff --git a/scarb/tests/profiles.rs b/scarb/tests/profiles.rs index 57b262104..4e8aed390 100644 --- a/scarb/tests/profiles.rs +++ b/scarb/tests/profiles.rs @@ -611,6 +611,7 @@ fn profile_overrides_tool() { [profile.release.tool.snforge] some-key = "some-other-value" "#}) + .dep_cairo_test() .build(&t); let metadata = Scarb::quick_snapbox() .args(["--json", "metadata", "--format-version", "1"]) diff --git a/utils/scarb-test-support/src/project_builder.rs b/utils/scarb-test-support/src/project_builder.rs index b19bf8095..34b6ce482 100644 --- a/utils/scarb-test-support/src/project_builder.rs +++ b/utils/scarb-test-support/src/project_builder.rs @@ -97,6 +97,10 @@ impl ProjectBuilder { self.dep("starknet", Dep.version(CAIRO_VERSION)) } + pub fn dep_cairo_test(self) -> Self { + self.dev_dep("cairo_test", Dep.version(CAIRO_VERSION)) + } + pub fn manifest_package_extra(mut self, extra: impl ToString) -> Self { self.manifest_package_extra = extra.to_string(); self