Skip to content

Commit 0819f81

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 2bbd337 commit 0819f81

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
@@ -294,6 +294,14 @@ impl<'a> ClientCommandContext<'a> {
294294
.log_download_method
295295
.clone())
296296
}
297+
298+
pub fn test_builds_targets(&self) -> buck2_error::Result<bool> {
299+
Ok(self
300+
.immediate_config
301+
.daemon_startup_config()?
302+
.test_builds_targets
303+
.clone())
304+
}
297305
}
298306

299307
/// 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
@@ -437,6 +437,7 @@ pub struct DaemonStartupConfig {
437437
pub resource_control: ResourceControlConfig,
438438
pub log_download_method: LogDownloadMethod,
439439
pub health_check_config: HealthCheckConfig,
440+
pub test_builds_targets: bool,
440441
}
441442

442443
impl DaemonStartupConfig {
@@ -512,6 +513,12 @@ impl DaemonStartupConfig {
512513
resource_control: ResourceControlConfig::from_config(config)?,
513514
log_download_method,
514515
health_check_config: HealthCheckConfig::from_config(config)?,
516+
test_builds_targets: config
517+
.parse(BuckconfigKeyRef {
518+
section: "buck2",
519+
property: "test_builds_targets",
520+
})?
521+
.unwrap_or(false),
515522
})
516523
}
517524

@@ -539,6 +546,7 @@ impl DaemonStartupConfig {
539546
LogDownloadMethod::None
540547
},
541548
health_check_config: HealthCheckConfig::default(),
549+
test_builds_targets: false,
542550
}
543551
}
544552
}

0 commit comments

Comments
 (0)