Commit 67fc1fc1 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

ptest: Add `list` command



The `list` command will show what tests are available.

Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent c32ad20f
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -40,10 +40,6 @@ fn main() -> Result<()> {

    let args = Cli::parse();

    match args.command {
        Commands::Run => (),
    }

    let workflow_text = fs::read_to_string(&args.workflow)?;
    let workflow = YamlLoader::load_from_str(&workflow_text)?;

@@ -52,6 +48,14 @@ fn main() -> Result<()> {

    let matrix = Matrix::from_yaml(&workflow);

    match args.command {
        Commands::List => {
            matrix.show();
            return Ok(());
        }
        Commands::Run => (),
    }

    let mut children = vec![];
    let state = State::new(matrix.envs.len());
    let st2 = state.clone();
@@ -100,6 +104,8 @@ struct Cli {
enum Commands {
    /// Runs the tests.
    Run,
    /// List available tests.
    List,
}

/// State, for printing status.
@@ -246,6 +252,13 @@ impl Matrix {
            envs,
        }
    }

    /// Print out all of the feature sets.
    fn show(&self) {
        for (i, feature) in self.envs.iter().enumerate() {
            println!("{:3}. {}", i, feature.simple_textual());
        }
    }
}

impl FeatureSet {
@@ -304,6 +317,18 @@ impl FeatureSet {

        buf
    }

    /// Generate a simpler textual representation, without showing the environment.
    fn simple_textual(&self) -> String {
        use std::fmt::Write;

        let mut buf = String::new();
        for v in &self.values {
            write!(&mut buf, " {}", v).unwrap();
        }

        buf
    }
}

fn lookup_matrix(y: &Yaml) -> Option<&Vec<Yaml>> {