Skip to content

Commit

Permalink
test: for verifying changes in manifest file (#804)
Browse files Browse the repository at this point in the history
* Prepare 0.2.1 (#817)

* add test for verifying changes in manifest file

* rework tests

* update manifest file after rebase

* clean up

* fix generated file path

* make clippy overlords happy

* remove unnecessary changes

* use symbolic link instead of copying

---------

Co-authored-by: Tarrence van As <tarrencev@users.noreply.github.com>
  • Loading branch information
lambda-0x and tarrencev authored Aug 23, 2023
1 parent bec0ca2 commit 7b18a3b
Show file tree
Hide file tree
Showing 9 changed files with 1,113 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/target
**/target
workspace
.idea/
dojo.iml
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/dojo-lang/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,7 @@ impl Manifest {
Ok(())
}
}

#[cfg(test)]
#[path = "manifest_test.rs"]
mod test;
35 changes: 35 additions & 0 deletions crates/dojo-lang/src/manifest_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::path::Path;
use std::{env, fs};

use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use dojo_test_utils::compiler::build_test_config;
use scarb::ops;

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<String, String>,
) -> OrderedHashMap<String, String> {
let config =
build_test_config("./src/manifest_test_data/manifest_test_crate/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:?}"));

let target_dir = config.target_dir().path_existent().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();

OrderedHashMap::from([("expected_manifest_file".into(), generated_file)])
}
1 change: 0 additions & 1 deletion crates/dojo-lang/src/manifest_test_crate/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions crates/dojo-lang/src/manifest_test_crate/Scarb.toml

This file was deleted.

1 change: 0 additions & 1 deletion crates/dojo-lang/src/manifest_test_crate/src/lib.cairo

This file was deleted.

Loading

0 comments on commit 7b18a3b

Please sign in to comment.