Skip to content

Commit 4a08735

Browse files
committed
update suggest-tests
1 parent 5a562d9 commit 4a08735

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

Diff for: src/bootstrap/src/core/build_steps/suggest.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ use crate::core::builder::Builder;
99

1010
/// Suggests a list of possible `x.py` commands to run based on modified files in branch.
1111
pub fn suggest(builder: &Builder<'_>, run: bool) {
12-
let suggestions =
13-
builder.tool_cmd(Tool::SuggestTests).output().expect("failed to run `suggest-tests` tool");
12+
let git_config = builder.config.git_config();
13+
let suggestions = builder
14+
.tool_cmd(Tool::SuggestTests)
15+
.env("SUGGEST_TESTS_GITHUB_REPOSITORY", git_config.github_repository)
16+
.env("SUGGEST_TESTS_NIGHTLY_BRANCH", git_config.nightly_branch)
17+
.output()
18+
.expect("failed to run `suggest-tests` tool");
1419

1520
if !suggestions.status.success() {
1621
println!("failed to run `suggest-tests` tool ({})", suggestions.status);

Diff for: src/tools/suggest-tests/src/main.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
use std::process::ExitCode;
22

3-
use build_helper::git::get_git_modified_files;
3+
use build_helper::git::{get_git_modified_files, GitConfig};
44
use suggest_tests::get_suggestions;
55

66
fn main() -> ExitCode {
7-
let modified_files = get_git_modified_files(None, &Vec::new());
7+
let modified_files = get_git_modified_files(
8+
&GitConfig {
9+
github_repository: &env("SUGGEST_TESTS_GITHUB_REPOSITORY"),
10+
nightly_branch: &env("SUGGEST_TESTS_NIGHTLY_BRANCH"),
11+
},
12+
None,
13+
&Vec::new(),
14+
);
815
let modified_files = match modified_files {
916
Ok(Some(files)) => files,
1017
Ok(None) => {
@@ -25,3 +32,13 @@ fn main() -> ExitCode {
2532

2633
ExitCode::SUCCESS
2734
}
35+
36+
fn env(key: &str) -> String {
37+
match std::env::var(key) {
38+
Ok(var) => var,
39+
Err(err) => {
40+
eprintln!("suggest-tests: failed to read environment variable {key}: {err}");
41+
std::process::exit(1);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)