update suggest-tests
This commit is contained in:
parent
5a562d962e
commit
4a0873533f
2 changed files with 26 additions and 4 deletions
|
|
@ -9,8 +9,13 @@ use crate::core::builder::Builder;
|
|||
|
||||
/// Suggests a list of possible `x.py` commands to run based on modified files in branch.
|
||||
pub fn suggest(builder: &Builder<'_>, run: bool) {
|
||||
let suggestions =
|
||||
builder.tool_cmd(Tool::SuggestTests).output().expect("failed to run `suggest-tests` tool");
|
||||
let git_config = builder.config.git_config();
|
||||
let suggestions = builder
|
||||
.tool_cmd(Tool::SuggestTests)
|
||||
.env("SUGGEST_TESTS_GITHUB_REPOSITORY", git_config.github_repository)
|
||||
.env("SUGGEST_TESTS_NIGHTLY_BRANCH", git_config.nightly_branch)
|
||||
.output()
|
||||
.expect("failed to run `suggest-tests` tool");
|
||||
|
||||
if !suggestions.status.success() {
|
||||
println!("failed to run `suggest-tests` tool ({})", suggestions.status);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
use std::process::ExitCode;
|
||||
|
||||
use build_helper::git::get_git_modified_files;
|
||||
use build_helper::git::{get_git_modified_files, GitConfig};
|
||||
use suggest_tests::get_suggestions;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let modified_files = get_git_modified_files(None, &Vec::new());
|
||||
let modified_files = get_git_modified_files(
|
||||
&GitConfig {
|
||||
github_repository: &env("SUGGEST_TESTS_GITHUB_REPOSITORY"),
|
||||
nightly_branch: &env("SUGGEST_TESTS_NIGHTLY_BRANCH"),
|
||||
},
|
||||
None,
|
||||
&Vec::new(),
|
||||
);
|
||||
let modified_files = match modified_files {
|
||||
Ok(Some(files)) => files,
|
||||
Ok(None) => {
|
||||
|
|
@ -25,3 +32,13 @@ fn main() -> ExitCode {
|
|||
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
fn env(key: &str) -> String {
|
||||
match std::env::var(key) {
|
||||
Ok(var) => var,
|
||||
Err(err) => {
|
||||
eprintln!("suggest-tests: failed to read environment variable {key}: {err}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue