Skip to content

Commit

Permalink
Add cairo-run function selection tests (#1388)
Browse files Browse the repository at this point in the history
commit-id:58797ffe
  • Loading branch information
maciektr authored Jun 24, 2024
1 parent 5cf4d55 commit 4e94529
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 76 deletions.
76 changes: 0 additions & 76 deletions extensions/scarb-cairo-run/tests/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,79 +358,3 @@ fn can_control_verbosity() {
something
"#});
}

#[test]
fn can_choose_function_to_run_by_name() {
let t = TempDir::new().unwrap();
ProjectBuilder::start()
.name("hello")
.version("0.1.0")
.lib_cairo(indoc! {r#"
fn a() {
println!("A");
}
fn main() {
println!("M");
}
fn b() {
println!("B");
}
"#})
.build(&t);
Scarb::quick_snapbox()
.arg("--quiet")
.arg("cairo-run")
.arg("--function")
.arg("b")
.current_dir(&t)
.assert()
.success()
.stdout_matches(indoc! {r#"
B
"#});
Scarb::quick_snapbox()
.arg("--quiet")
.arg("cairo-run")
.current_dir(&t)
.assert()
.success()
.stdout_matches(indoc! {r#"
M
"#});
}

#[test]
fn choose_not_existing_function() {
let t = TempDir::new().unwrap();
ProjectBuilder::start()
.name("hello")
.version("0.1.0")
.lib_cairo(indoc! {r#"
fn main() {
println!("main");
}
"#})
.build(&t);
let output = Scarb::quick_snapbox()
.arg("cairo-run")
.arg("--function")
.arg("b")
.current_dir(&t)
.assert()
.failure();
#[cfg(windows)]
output.stdout_matches(indoc! {r#"
[..]Compiling hello v0.1.0 ([..]Scarb.toml)
[..]Finished release target(s) in [..]
[..]Running hello
[..]error: Function with suffix `::b` to run not found.
error: process did not exit successfully: exit code: 1
"#});
#[cfg(not(windows))]
output.stdout_matches(indoc! {r#"
[..]Compiling hello v0.1.0 ([..]Scarb.toml)
[..]Finished release target(s) in [..]
[..]Running hello
[..]error: Function with suffix `::b` to run not found.
"#});
}
Loading

0 comments on commit 4e94529

Please sign in to comment.