Skip to content

Commit

Permalink
Move test project to clap (FuelLabs#2470)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlicanC authored Aug 10, 2022
1 parent 0a4ac5d commit 15f3aac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
27 changes: 14 additions & 13 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ publish = false

[dependencies]
anyhow = "1.0.41"
clap = "3.2.16"
filecheck = "0.5"
forc = { path = "../forc", features = ["test"], default-features = false }
forc-pkg = { path = "../forc-pkg" }
Expand Down
37 changes: 16 additions & 21 deletions test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
mod e2e_vm_tests;
mod ir_generation;

fn main() {
let mut locked = false;
let mut filter_regex = None;
for arg in std::env::args().skip(1) {
// Check for the `--locked` flag. Must precede the regex.
// Intended for use in `CI` to ensure test lock files are up to date.
if arg == "--locked" {
locked = true;
continue;
}
use clap::Parser;

#[derive(Parser)]
struct Cli {
/// If specified, only run tests matching this regex
#[clap(value_parser)]
filter_regex: Option<regex::Regex>,

// Check for a regex, used to filter the set of tests.
let regex = regex::Regex::new(&arg).unwrap_or_else(|_| {
panic!(
"Expected either `--locked` or a filter regex, found: {:?}.",
arg
)
});
filter_regex = Some(regex);
}
/// Intended for use in `CI` to ensure test lock files are up to date
#[clap(long)]
locked: bool,
}

fn main() {
let cli = Cli::parse();

e2e_vm_tests::run(locked, filter_regex.as_ref());
ir_generation::run(filter_regex.as_ref());
e2e_vm_tests::run(cli.locked, cli.filter_regex.as_ref());
ir_generation::run(cli.filter_regex.as_ref());
}

0 comments on commit 15f3aac

Please sign in to comment.