diff options
| author | Pietro Albini <pietro.albini@ferrous-systems.com> | 2023-10-24 12:03:30 +0200 |
|---|---|---|
| committer | Pietro Albini <pietro.albini@ferrous-systems.com> | 2023-10-24 12:03:30 +0200 |
| commit | 545cc830e1fb22fe180dea2f713e6472b52707f9 (patch) | |
| tree | 6065942a40bf714db25b5d227d5c0ac9e80f0e69 /src/tools/compiletest | |
| parent | 6eb3e97d5549f81bbdb8a5e94a005a338bc284ec (diff) | |
| download | rust-545cc830e1fb22fe180dea2f713e6472b52707f9.tar.gz rust-545cc830e1fb22fe180dea2f713e6472b52707f9.zip | |
allow configuring the parent GitHub repository
The git integration in build_helper hardcoded `rust-lang/rust` as the parent GitHub repository, and `master` as the branch name. This works great for `rust-lang/rust`, but causes problems in downstream forks like Ferrocene whenever those functions are invoked (like `./x fmt`). In `src/stage0.json` there was already a configuration key for the name of the nightly branch, but it wasn't used by build_helper. This commit adds the `github_repository` key to the file, and requires both values to be passed to build_helper whenever a git function is called. This will allow downstream forks to tweak the values.
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 12 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/tests.rs | 2 | ||||
| -rw-r--r-- | src/tools/compiletest/src/lib.rs | 12 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 0e1bf0c6c2d..cd9cf748aff 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -8,6 +8,7 @@ use std::process::Command; use std::str::FromStr; use crate::util::{add_dylib_path, PathBufExt}; +use build_helper::git::GitConfig; use lazycell::AtomicLazyCell; use serde::de::{Deserialize, Deserializer, Error as _}; use std::collections::{HashMap, HashSet}; @@ -370,6 +371,10 @@ pub struct Config { pub target_cfgs: AtomicLazyCell<TargetCfgs>, pub nocapture: bool, + + // Needed both to construct build_helper::git::GitConfig + pub github_repository: String, + pub nightly_branch: String, } impl Config { @@ -441,6 +446,13 @@ impl Config { ]; ASM_SUPPORTED_ARCHS.contains(&self.target_cfg().arch.as_str()) } + + pub fn git_config(&self) -> GitConfig<'_> { + GitConfig { + github_repository: &self.github_repository, + nightly_branch: &self.nightly_branch, + } + } } #[derive(Debug, Clone)] diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 2fd80b52cee..1c89f8ba763 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -126,6 +126,8 @@ impl ConfigBuilder { self.host.as_deref().unwrap_or("x86_64-unknown-linux-gnu"), "--target", self.target.as_deref().unwrap_or("x86_64-unknown-linux-gnu"), + "--github-repository=", + "--nightly-branch=", ]; let mut args: Vec<String> = args.iter().map(ToString::to_string).collect(); diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 619ff9b3221..52e7f4174f1 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -144,7 +144,9 @@ pub fn parse_config(args: Vec<String>) -> Config { .optflag("h", "help", "show this message") .reqopt("", "channel", "current Rust channel", "CHANNEL") .optflag("", "git-hash", "run tests which rely on commit version being compiled into the binaries") - .optopt("", "edition", "default Rust edition", "EDITION"); + .optopt("", "edition", "default Rust edition", "EDITION") + .reqopt("", "github-repository", "name of the GitHub repository", "ORG/REPO") + .reqopt("", "nightly-branch", "name of the git branch for nightly", "BRANCH"); let (argv0, args_) = args.split_first().unwrap(); if args.len() == 1 || args[1] == "-h" || args[1] == "--help" { @@ -307,6 +309,9 @@ pub fn parse_config(args: Vec<String>) -> Config { target_cfgs: AtomicLazyCell::new(), nocapture: matches.opt_present("nocapture"), + + github_repository: matches.opt_str("github-repository").unwrap(), + nightly_branch: matches.opt_str("nightly-branch").unwrap(), } } @@ -609,9 +614,10 @@ fn modified_tests(config: &Config, dir: &Path) -> Result<Vec<PathBuf>, String> { return Ok(vec![]); } let files = - get_git_modified_files(Some(dir), &vec!["rs", "stderr", "fixed"])?.unwrap_or(vec![]); + get_git_modified_files(&config.git_config(), Some(dir), &vec!["rs", "stderr", "fixed"])? + .unwrap_or(vec![]); // Add new test cases to the list, it will be convenient in daily development. - let untracked_files = get_git_untracked_files(None)?.unwrap_or(vec![]); + let untracked_files = get_git_untracked_files(&config.git_config(), None)?.unwrap_or(vec![]); let all_paths = [&files[..], &untracked_files[..]].concat(); let full_paths = { |
