Skip to content

Commit 8798337

Browse files
committed
ptest: Add command line parsing
Add a skeleton of a command line parser to the ptest utility. This will allow future changes to add additional options, such as listing and filtering the tests that are used. This adds a single subcommand `run`, which mimics the previous ptest behavior. Signed-off-by: David Brown <david.brown@linaro.org>
1 parent 556b32a commit 8798337

File tree

3 files changed

+211
-4
lines changed

3 files changed

+211
-4
lines changed

ptest/Cargo.lock

+185-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ptest/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ log = "0.4.17"
1212
num_cpus = "1.13.1"
1313
std-semaphore = "0.1"
1414
yaml-rust = "0.4"
15+
16+
[dependencies.clap]
17+
version = "4.0"
18+
features = ["derive"]

ptest/src/main.rs

+22
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//! jobs->environment->strategy->matric->features
1212
1313
use chrono::Local;
14+
use clap::{Parser, Subcommand};
1415
use log::{debug, error, warn};
1516
use std::{
1617
collections::HashSet,
@@ -37,6 +38,12 @@ type Result<T> = result::Result<T, failure::Error>;
3738
fn main() -> Result<()> {
3839
env_logger::init();
3940

41+
let args = Cli::parse();
42+
43+
match args.command {
44+
Commands::Run => (),
45+
}
46+
4047
let workflow_text = fs::read_to_string("../.github/workflows/sim.yaml")?;
4148
let workflow = YamlLoader::load_from_str(&workflow_text)?;
4249

@@ -76,6 +83,21 @@ fn main() -> Result<()> {
7683
Ok(())
7784
}
7885

86+
/// The main Cli.
87+
#[derive(Debug, Parser)]
88+
#[command(name = "ptest")]
89+
#[command(about = "Run MCUboot CI tests stand alone")]
90+
struct Cli {
91+
#[command(subcommand)]
92+
command: Commands,
93+
}
94+
95+
#[derive(Debug, Subcommand)]
96+
enum Commands {
97+
/// Runs the tests.
98+
Run,
99+
}
100+
79101
/// State, for printing status.
80102
struct State {
81103
running: HashSet<String>,

0 commit comments

Comments
 (0)