Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use packages filter env var in cairo-test #723

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions extensions/scarb-cairo-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ fn main() -> Result<()> {

check_scarb_version(&metadata);

let matched = args.packages_filter.match_many(&metadata)?;
let filter = PackagesFilter::generate_for::<Metadata>(matched.iter());
ScarbCommand::new()
.arg("build")
.arg("--test")
.env("SCARB_PACKAGES_FILTER", filter.to_env())
.run()?;

let profile = env::var("SCARB_PROFILE").unwrap_or("dev".into());
let default_target_dir = metadata.runtime_manifest.join("target");
let target_dir = metadata
Expand All @@ -43,16 +51,9 @@ fn main() -> Result<()> {
.unwrap_or(default_target_dir)
.join(profile);

for package in args.packages_filter.match_many(&metadata)? {
for package in matched {
println!("testing {} ...", package.name);

ScarbCommand::new()
.arg("build")
.arg("--test")
.arg("-p")
.arg(package.name)
.run()?;

for target in find_testable_targets(&metadata, &package.id) {
let file_path = target_dir.join(format!("{}.test.json", target.name.clone()));
let test_compilation = serde_json::from_str::<TestCompilation>(
Expand Down
1 change: 1 addition & 0 deletions extensions/scarb-cairo-test/tests/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use test_for_each_example::test_for_each_example;
fn cairo_test(example: &Path) {
Command::new(cargo_bin("scarb"))
.arg("cairo-test")
.arg("--workspace")
mkaput marked this conversation as resolved.
Show resolved Hide resolved
.current_dir(example)
.assert()
.success();
Expand Down