Skip to content

Commit

Permalink
chain sim - cleanup sc-meta test
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaIalangi committed Oct 15, 2024
1 parent d27f419 commit 563789f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 213 deletions.
1 change: 0 additions & 1 deletion contracts/examples/adder/interact/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ path = ".."
[dependencies.multiversx-sc-snippets]
version = "0.53.2"
path = "../../../../framework/snippets"
features = ["chain_simulator"]

[features]
chain_simulator = []
47 changes: 16 additions & 31 deletions framework/meta/src/cmd/test.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
use std::process::Command;

use colored::Colorize;
use interactor_tests::perform_tests_interactor;

use crate::cli::TestArgs;

mod interactor_test_analyzer;
mod interactor_tests;
mod simulator_setup;

pub fn test(test_args: &TestArgs) {
let path = test_args.path.as_deref().unwrap_or("./");
let mut program = "cargo";
Expand All @@ -19,58 +14,48 @@ pub fn test(test_args: &TestArgs) {
let no_capture = test_args.nocapture;
let chain_simulator = test_args.chain_simulator;

if chain_simulator && !go {
perform_tests_interactor(path);
return;
}

if scen {
program = "mx-scenario-go";
args.extend(["run", "./"]);

if go {
println!("{}", "If scen parameter is true, it will override the go parameter. Executing scenarios...".yellow());
}
} else {
args.push("test");

execute_and_print(path, program, &args);
}

args.push("test");

if go {
args.extend(["--features", "multiversx-sc-scenario/run-go-tests"]);
}
if go {
args.extend(["--features", "multiversx-sc-scenario/run-go-tests"]);
}

if no_capture {
args.extend(["--", "--nocapture"]);
}
if chain_simulator {
args.extend(["--features", "chain_simulator"]);
}

if chain_simulator {
perform_tests_interactor(path);
if no_capture {
args.extend(["--", "--nocapture"]);
}
}

execute_and_print(path, program, &args);
}

fn execute_and_print(file_path: &str, program: &str, args: &[&str]) {
let args_str = args.join(" ");

println!(
"{}\n{}",
format!("Running tests in {file_path} ...").green(),
format!("Running tests in {path} ...").green(),
format!("Executing {program} {args_str} ...").green()
);

let status = Command::new(program)
.args(args)
.current_dir(file_path)
.args(args.clone())
.current_dir(path)
.status()
.unwrap_or_else(|_| {
panic!(
"{}",
format!("Failed to run: {program} {args_str}").bright_red()
format!("Failed to run program: {program} {args_str}").bright_red()
)
});

println!("Process finished with: {status}");
assert!(status.success());
}
54 changes: 0 additions & 54 deletions framework/meta/src/cmd/test/interactor_test_analyzer.rs

This file was deleted.

76 changes: 0 additions & 76 deletions framework/meta/src/cmd/test/interactor_tests.rs

This file was deleted.

48 changes: 0 additions & 48 deletions framework/meta/src/cmd/test/simulator_setup.rs

This file was deleted.

3 changes: 0 additions & 3 deletions framework/snippets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ env_logger = "0.11"
futures = "0.3"
anyhow = "1.0.44"

[features]
chain_simulator = []

[dependencies.multiversx-sc-scenario]
version = "=0.53.2"
path = "../scenario"
Expand Down

0 comments on commit 563789f

Please sign in to comment.