Skip to content

Commit 921adb4

Browse files
committed
test: allow buck2.test_builds_targets to build all RunInfo and DefaultInfos by default
Signed-off-by: Austin Seipp <[email protected]>
1 parent 31bb014 commit 921adb4

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

app/buck2_client/src/commands/test.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ If include patterns are present, regardless of whether exclude patterns are pres
159159
build_default_info: bool,
160160

161161
/// Do not build DefaultInfo provider (this is the default)
162-
#[allow(unused)]
163162
#[clap(long, group = "default-info")]
164163
skip_default_info: bool,
165164

@@ -168,7 +167,6 @@ If include patterns are present, regardless of whether exclude patterns are pres
168167
build_run_info: bool,
169168

170169
/// Do not build RunInfo provider (this is the default)
171-
#[allow(unused)]
172170
#[clap(long, group = "run-info")]
173171
skip_run_info: bool,
174172

@@ -205,6 +203,23 @@ impl StreamingCommand for TestCommand {
205203
events_ctx: &mut EventsCtx,
206204
) -> ExitResult {
207205
let context = ctx.client_context(matches, &self)?;
206+
207+
let build_default_info = if self.skip_default_info {
208+
false
209+
} else if self.build_default_info {
210+
true
211+
} else {
212+
ctx.test_builds_targets()?
213+
};
214+
215+
let build_run_info = if self.skip_run_info {
216+
false
217+
} else if self.build_run_info {
218+
true
219+
} else {
220+
ctx.test_builds_targets()?
221+
};
222+
208223
let response = buckd
209224
.with_flushing()
210225
.test(
@@ -228,8 +243,8 @@ impl StreamingCommand for TestCommand {
228243
}),
229244
timeout: self.timeout_options.overall_timeout()?,
230245
ignore_tests_attribute: self.ignore_tests_attribute,
231-
build_default_info: self.build_default_info,
232-
build_run_info: self.build_run_info,
246+
build_default_info,
247+
build_run_info,
233248
},
234249
events_ctx,
235250
ctx.console_interaction_stream(&self.common_opts.console_opts),

app/buck2_client_ctx/src/client_ctx.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ impl<'a> ClientCommandContext<'a> {
292292
.log_download_method
293293
.clone())
294294
}
295+
296+
pub fn test_builds_targets(&self) -> buck2_error::Result<bool> {
297+
Ok(self
298+
.immediate_config
299+
.daemon_startup_config()?
300+
.test_builds_targets
301+
.clone())
302+
}
295303
}
296304

297305
/// Provides a common interface for buck subcommands that use event subscribers for logging.

app/buck2_common/src/init.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ pub struct DaemonStartupConfig {
446446
pub resource_control: ResourceControlConfig,
447447
pub log_download_method: LogDownloadMethod,
448448
pub health_check_config: HealthCheckConfig,
449+
pub test_builds_targets: bool,
449450
}
450451

451452
impl DaemonStartupConfig {
@@ -521,6 +522,12 @@ impl DaemonStartupConfig {
521522
resource_control: ResourceControlConfig::from_config(config)?,
522523
log_download_method,
523524
health_check_config: HealthCheckConfig::from_config(config)?,
525+
test_builds_targets: config
526+
.parse(BuckconfigKeyRef {
527+
section: "buck2",
528+
property: "test_builds_targets",
529+
})?
530+
.unwrap_or(false),
524531
})
525532
}
526533

@@ -548,6 +555,7 @@ impl DaemonStartupConfig {
548555
LogDownloadMethod::None
549556
},
550557
health_check_config: HealthCheckConfig::default(),
558+
test_builds_targets: false,
551559
}
552560
}
553561
}

0 commit comments

Comments
 (0)