Skip to content

Commit

Permalink
filter out none and all, and explain default try logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilgardis committed Feb 1, 2024
1 parent 4197044 commit 5ae2acd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions xtask/src/ci/target_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ impl TargetMatrix {
_ => (vec![], TargetMatrixArgs::default()),
};

// only apply ci labels on prs and `/ci try`,
// if the try command is not the default, we don't want to apply ci labels
if matches!(
self,
Self {
Expand Down Expand Up @@ -362,26 +364,27 @@ impl TargetMatrixArgs {
map.end()
}
}
let tests = match (
let mut tests = match (
self.tests.iter().any(|t| t == "all"),
self.tests.iter().any(|t| t == "none"),
) {
(_, true) => vec![],
(true, false) => {
let mut possible: Vec<String> = Self::command()
let possible: Vec<String> = Self::command()
.get_arguments()
.find(|arg| arg.get_id() == "tests")
.expect("a `tests` argument should exist")
.get_possible_values()
.into_iter()
.map(|p| p.get_name().to_owned())
.collect();
possible.retain(|p| p != "all");
possible.retain(|p| p != "none");

possible
}
_ => self.tests.clone(),
};
tests.retain(|p| p != "all");
tests.retain(|p| p != "none");
serde_json::to_value(Ser(tests))
}
}
Expand Down

0 comments on commit 5ae2acd

Please sign in to comment.