Skip to content

Commit e21e5c2

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 47d7b10 commit e21e5c2

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
@@ -288,6 +288,14 @@ impl<'a> ClientCommandContext<'a> {
288288
.log_download_method
289289
.clone())
290290
}
291+
292+
pub fn test_builds_targets(&self) -> buck2_error::Result<bool> {
293+
Ok(self
294+
.immediate_config
295+
.daemon_startup_config()?
296+
.test_builds_targets
297+
.clone())
298+
}
291299
}
292300

293301
/// 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
@@ -403,6 +403,7 @@ pub struct DaemonStartupConfig {
403403
pub resource_control: ResourceControlConfig,
404404
pub log_download_method: LogDownloadMethod,
405405
pub health_check_config: HealthCheckConfig,
406+
pub test_builds_targets: bool,
406407
}
407408

408409
impl DaemonStartupConfig {
@@ -478,6 +479,12 @@ impl DaemonStartupConfig {
478479
resource_control: ResourceControlConfig::from_config(config)?,
479480
log_download_method,
480481
health_check_config: HealthCheckConfig::from_config(config)?,
482+
test_builds_targets: config
483+
.parse(BuckconfigKeyRef {
484+
section: "buck2",
485+
property: "test_builds_targets",
486+
})?
487+
.unwrap_or(false),
481488
})
482489
}
483490

@@ -505,6 +512,7 @@ impl DaemonStartupConfig {
505512
LogDownloadMethod::None
506513
},
507514
health_check_config: HealthCheckConfig::default(),
515+
test_builds_targets: false,
508516
}
509517
}
510518
}

0 commit comments

Comments
 (0)