From 44cab3982f1d52f05dbf8655ad093584f3c8838f Mon Sep 17 00:00:00 2001 From: Kariy Date: Wed, 25 Oct 2023 01:24:38 +0900 Subject: [PATCH] rebamse main --- crates/dojo-lang/src/compiler.rs | 19 ----------- crates/dojo-lang/src/compiler_test.rs | 30 ++++++++++++++---- crates/dojo-lang/src/manifest_test.rs | 45 --------------------------- 3 files changed, 24 insertions(+), 70 deletions(-) delete mode 100644 crates/dojo-lang/src/manifest_test.rs diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index 0cd7e58539..889cc00a22 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -200,24 +200,6 @@ pub fn collect_external_crate_ids( .collect::>() } -<<<<<<< HEAD -#[test] -fn test_compiler() { - use dojo_test_utils::compiler::build_test_config; - use scarb::ops; - use scarb::ops::CompileOpts; - - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let packages = ws.members().map(|p| p.id).collect(); - ops::compile( - packages, - CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, - &ws, - ) - .unwrap_or_else(|op| panic!("Error compiling: {op:?}")) -======= fn update_manifest( manifest: &mut dojo_world::manifest::Manifest, db: &dyn SemanticGroup, @@ -391,5 +373,4 @@ fn do_update_manifest( } Ok(()) ->>>>>>> eb0865dd (prevent overwrite on build) } diff --git a/crates/dojo-lang/src/compiler_test.rs b/crates/dojo-lang/src/compiler_test.rs index 82654c3db3..479998d795 100644 --- a/crates/dojo-lang/src/compiler_test.rs +++ b/crates/dojo-lang/src/compiler_test.rs @@ -1,16 +1,26 @@ use std::path::Path; use std::{env, fs}; +use cairo_lang_test_utils::parse_test_file::TestRunnerResult; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use dojo_test_utils::compiler::build_test_config; -use scarb::ops; +use scarb::core::TargetKind; +use scarb::ops::{self, CompileOpts}; #[test] fn test_compiler() { let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); let packages = ws.members().map(|p| p.id).collect(); - assert!(ops::compile(packages, &ws).is_ok(), "compilation failed"); + assert!( + ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws + ) + .is_ok(), + "compilation failed" + ); } cairo_lang_test_utils::test_file_test!( @@ -25,19 +35,27 @@ cairo_lang_test_utils::test_file_test!( pub fn test_manifest_file( _inputs: &OrderedHashMap, _args: &OrderedHashMap, -) -> Result, String> { +) -> TestRunnerResult { let config = build_test_config("./src/manifest_test_data/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); let packages = ws.members().map(|p| p.id).collect(); - ops::compile(packages, &ws).unwrap_or_else(|op| panic!("Error compiling: {op:?}")); + ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws, + ) + .unwrap_or_else(|op| panic!("Error compiling: {op:?}")); - let target_dir = config.target_dir().path_existent().unwrap(); + let target_dir = config.target_dir_override().unwrap(); let generated_manifest_path = Path::new(target_dir).join(config.profile().as_str()).join("manifest.json"); let generated_file = fs::read_to_string(generated_manifest_path).unwrap(); - Ok(OrderedHashMap::from([("expected_manifest_file".into(), generated_file)])) + TestRunnerResult::success(OrderedHashMap::from([( + "expected_manifest_file".into(), + generated_file, + )])) } diff --git a/crates/dojo-lang/src/manifest_test.rs b/crates/dojo-lang/src/manifest_test.rs deleted file mode 100644 index d04f1ac5f5..0000000000 --- a/crates/dojo-lang/src/manifest_test.rs +++ /dev/null @@ -1,45 +0,0 @@ -use std::path::Path; -use std::{env, fs}; - -use cairo_lang_test_utils::parse_test_file::TestRunnerResult; -use cairo_lang_utils::ordered_hash_map::OrderedHashMap; -use dojo_test_utils::compiler::build_test_config; -use scarb::core::TargetKind; -use scarb::ops::{self, CompileOpts}; - -cairo_lang_test_utils::test_file_test!( - manifest_file, - "src/manifest_test_data/", - { - manifest: "manifest", - }, - test_manifest_file -); - -pub fn test_manifest_file( - _inputs: &OrderedHashMap, - _args: &OrderedHashMap, -) -> TestRunnerResult { - let config = build_test_config("./src/manifest_test_data/spawn-and-move/Scarb.toml").unwrap(); - let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); - - let packages = ws.members().map(|p| p.id).collect(); - ops::compile( - packages, - CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, - &ws, - ) - .unwrap_or_else(|op| panic!("Error compiling: {op:?}")); - - let target_dir = config.target_dir_override().unwrap(); - - let generated_manifest_path = - Path::new(target_dir).join(config.profile().as_str()).join("manifest.json"); - - let generated_file = fs::read_to_string(generated_manifest_path).unwrap(); - - TestRunnerResult::success(OrderedHashMap::from([( - "expected_manifest_file".into(), - generated_file, - )])) -}