Skip to content

Commit 671aabd

Browse files
committed
add dry_run flag in config builder and remove runtime test hacks
1 parent 9189bf7 commit 671aabd

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

src/bootstrap/src/core/config/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn invalid_rust_optimize() {
234234

235235
#[test]
236236
fn verify_file_integrity() {
237-
let config = TestCtx::new().config("check").create_config();
237+
let config = TestCtx::new().config("check").no_dry_run().create_config();
238238

239239
let tempfile = config.tempdir().join(".tmp-test-file");
240240
File::create(&tempfile).unwrap().write_all(b"dummy value").unwrap();

src/bootstrap/src/core/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ pub(crate) fn verify(exec_ctx: &ExecutionContext, path: &Path, expected: &str) -
857857
println!("verifying {}", path.display());
858858
});
859859

860-
if exec_ctx.dry_run() && !cfg!(test) {
860+
if exec_ctx.dry_run() {
861861
return false;
862862
}
863863

src/bootstrap/src/utils/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl Drop for TimeIt {
160160
/// Symlinks two directories, using junctions on Windows and normal symlinks on
161161
/// Unix.
162162
pub fn symlink_dir(config: &Config, original: &Path, link: &Path) -> io::Result<()> {
163-
if config.dry_run() && !cfg!(test) {
163+
if config.dry_run() {
164164
return Ok(());
165165
}
166166
let _ = fs::remove_dir_all(link);

src/bootstrap/src/utils/helpers/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn test_check_cfg_arg() {
6060

6161
#[test]
6262
fn test_symlink_dir() {
63-
let config = TestCtx::new().config("check").create_config();
63+
let config = TestCtx::new().config("check").no_dry_run().create_config();
6464
let tempdir = config.tempdir().join(".tmp-dir");
6565
let link_path = config.tempdir().join(".tmp-link");
6666

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub struct ConfigBuilder {
4949
args: Vec<String>,
5050
directory: PathBuf,
5151
override_download_ci_llvm: bool,
52+
dry_run: bool,
5253
}
5354

5455
impl ConfigBuilder {
@@ -57,6 +58,7 @@ impl ConfigBuilder {
5758
args: args.iter().copied().map(String::from).collect(),
5859
directory,
5960
override_download_ci_llvm: true,
61+
dry_run: true,
6062
}
6163
}
6264

@@ -116,10 +118,16 @@ impl ConfigBuilder {
116118
self
117119
}
118120

119-
pub fn create_config(mut self) -> Config {
120-
// Run in dry-check, otherwise the test would be too slow
121-
self.args.push("--dry-run".to_string());
121+
pub fn no_dry_run(mut self) -> Self {
122+
self.dry_run = false;
123+
self
124+
}
122125

126+
pub fn create_config(mut self) -> Config {
127+
if self.dry_run {
128+
// Run in dry-check, otherwise the test would be too slow
129+
self.args.push("--dry-run".to_string());
130+
}
123131
// Ignore submodules
124132
self.args.push("--set".to_string());
125133
self.args.push("build.submodules=false".to_string());

0 commit comments

Comments
 (0)