Skip to content

Commit 0ceb85a

Browse files
committed
ptest: Add --test argument
The `--test` (`-t`) argument allows the caller to limit the tests that are invoked by ptest. The argument can be specified multiple times to run several tests. The numbers are based on the output of `--list`. Signed-off-by: David Brown <david.brown@linaro.org>
1 parent 67fc1fc commit 0ceb85a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ptest/src/main.rs

+22
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ fn main() -> Result<()> {
4848

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

51+
let matrix = if args.test.len() == 0 { matrix } else {
52+
matrix.only(&args.test)
53+
};
54+
5155
match args.command {
5256
Commands::List => {
5357
matrix.show();
@@ -96,6 +100,10 @@ struct Cli {
96100
#[arg(short, long, default_value = "../.github/workflows/sim.yaml")]
97101
workflow: String,
98102

103+
/// The tests to run (defaults to all)
104+
#[arg(short, long)]
105+
test: Vec<usize>,
106+
99107
#[command(subcommand)]
100108
command: Commands,
101109
}
@@ -259,6 +267,20 @@ impl Matrix {
259267
println!("{:3}. {}", i, feature.simple_textual());
260268
}
261269
}
270+
271+
/// Replace this matrix with one that only has the chosen tests in it. Note
272+
/// that the original order is preserved, not that given in `pick`.
273+
fn only(self, pick: &[usize]) -> Self {
274+
let pick: HashSet<usize> = pick.iter().cloned().collect();
275+
let envs: Vec<_> = self
276+
.envs
277+
.into_iter()
278+
.enumerate()
279+
.filter(|(ind, _)| pick.contains(ind))
280+
.map(|(_, item)| item)
281+
.collect();
282+
Matrix { envs }
283+
}
262284
}
263285

264286
impl FeatureSet {

0 commit comments

Comments
 (0)