Skip to content

Commit 9189bf7

Browse files
committed
remove create_config_without_ci_llvm_override duplication
1 parent 0c68c82 commit 9189bf7

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

src/bootstrap/src/core/builder/tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ fn parse_config_download_rustc_at(path: &Path, download_rustc: &str, ci: bool) -
227227
"--src",
228228
path.to_str().unwrap(),
229229
])
230-
.create_config_without_ci_llvm_override()
230+
.no_override_download_ci_llvm()
231+
.create_config()
231232
}
232233

233234
mod dist {

src/bootstrap/src/utils/tests/mod.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ impl TestCtx {
4848
pub struct ConfigBuilder {
4949
args: Vec<String>,
5050
directory: PathBuf,
51+
override_download_ci_llvm: bool,
5152
}
5253

5354
impl ConfigBuilder {
5455
fn from_args(args: &[&str], directory: PathBuf) -> Self {
55-
Self { args: args.iter().copied().map(String::from).collect(), directory }
56+
Self {
57+
args: args.iter().copied().map(String::from).collect(),
58+
directory,
59+
override_download_ci_llvm: true,
60+
}
5661
}
5762

5863
pub fn path(mut self, path: &str) -> Self {
@@ -106,34 +111,26 @@ impl ConfigBuilder {
106111
self
107112
}
108113

109-
pub fn create_config(mut self) -> Config {
110-
// Run in dry-check, otherwise the test would be too slow
111-
self.args.push("--dry-run".to_string());
112-
113-
// Ignore submodules
114-
self.args.push("--set".to_string());
115-
self.args.push("build.submodules=false".to_string());
116-
117-
// Override any external LLVM set and inhibit CI LLVM; pretend that we're always building
118-
// in-tree LLVM from sources.
119-
self.args.push("--set".to_string());
120-
self.args.push("llvm.download-ci-llvm=false".to_string());
121-
122-
// Do not mess with the local rustc checkout build directory
123-
self.args.push("--build-dir".to_string());
124-
self.args.push(self.directory.join("build").display().to_string());
125-
126-
Config::parse(Flags::parse(&self.args))
114+
pub fn no_override_download_ci_llvm(mut self) -> Self {
115+
self.override_download_ci_llvm = false;
116+
self
127117
}
128118

129-
pub fn create_config_without_ci_llvm_override(mut self) -> Config {
119+
pub fn create_config(mut self) -> Config {
130120
// Run in dry-check, otherwise the test would be too slow
131121
self.args.push("--dry-run".to_string());
132122

133123
// Ignore submodules
134124
self.args.push("--set".to_string());
135125
self.args.push("build.submodules=false".to_string());
136126

127+
if self.override_download_ci_llvm {
128+
// Override any external LLVM set and inhibit CI LLVM; pretend that we're always building
129+
// in-tree LLVM from sources.
130+
self.args.push("--set".to_string());
131+
self.args.push("llvm.download-ci-llvm=false".to_string());
132+
}
133+
137134
// Do not mess with the local rustc checkout build directory
138135
self.args.push("--build-dir".to_string());
139136
self.args.push(self.directory.join("build").display().to_string());

0 commit comments

Comments
 (0)