Skip to content

Commit e8417ae

Browse files
committed
[bot/smoketest-cli-path-override]: rewrite on commit base commit
1 parent c9c7115 commit e8417ae

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

crates/smoketests/src/lib.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ pub struct Smoketest {
467467
module_name: String,
468468
/// Path to pre-compiled WASM file (if using precompiled_module).
469469
precompiled_wasm_path: Option<PathBuf>,
470+
/// Optional path to a specific CLI binary to run for this test.
471+
cli_path: Option<PathBuf>,
470472
}
471473

472474
/// Response from an HTTP API call.
@@ -726,6 +728,7 @@ pub struct SmoketestBuilder {
726728
autopublish: bool,
727729
pg_port: Option<u16>,
728730
server_url_override: Option<String>,
731+
cli_path: Option<PathBuf>,
729732
}
730733

731734
struct DataDirFixture {
@@ -751,6 +754,7 @@ impl SmoketestBuilder {
751754
autopublish: true,
752755
pg_port: None,
753756
server_url_override: None,
757+
cli_path: None,
754758
}
755759
}
756760

@@ -759,6 +763,12 @@ impl SmoketestBuilder {
759763
self
760764
}
761765

766+
/// Uses a specific CLI binary instead of the pre-built CLI for this test.
767+
pub fn cli_path(mut self, path: impl AsRef<Path>) -> Self {
768+
self.cli_path = Some(path.as_ref().to_path_buf());
769+
self
770+
}
771+
762772
/// Starts the local server from a copy of a persisted standalone data directory fixture.
763773
///
764774
/// The fixture directory is copied to a temporary directory before startup so tests can
@@ -840,7 +850,9 @@ impl SmoketestBuilder {
840850
/// Run `cargo smoketest prepare` to build binaries before running tests.
841851
pub fn build(self) -> Smoketest {
842852
// Check binaries first - this will panic with a helpful message if missing/stale
843-
let _ = ensure_binaries_built();
853+
if self.cli_path.is_none() {
854+
let _ = ensure_binaries_built();
855+
}
844856
let build_start = Instant::now();
845857

846858
let fixture_identity = self
@@ -921,6 +933,7 @@ impl SmoketestBuilder {
921933
config_path,
922934
module_name,
923935
precompiled_wasm_path: precompiled_wasm_path.clone(),
936+
cli_path: self.cli_path.clone(),
924937
bindings_features: self.bindings_features.clone(),
925938
extra_deps: self.extra_deps.clone(),
926939
};
@@ -950,6 +963,10 @@ pub fn noop(_ctx: &ReducerContext) {}
950963
}
951964

952965
impl Smoketest {
966+
fn cli_path(&self) -> PathBuf {
967+
self.cli_path.clone().unwrap_or_else(ensure_binaries_built)
968+
}
969+
953970
/// Creates a new builder for configuring a smoketest.
954971
pub fn builder() -> SmoketestBuilder {
955972
SmoketestBuilder::new()
@@ -1071,7 +1088,7 @@ impl Smoketest {
10711088
/// Callers should pass `--server` explicitly when the command needs it.
10721089
pub fn spacetime_cmd(&self, args: &[&str]) -> Output {
10731090
let start = Instant::now();
1074-
let cli_path = ensure_binaries_built();
1091+
let cli_path = self.cli_path();
10751092
let output = Command::new(&cli_path)
10761093
.arg("--config-path")
10771094
.arg(&self.config_path)
@@ -1092,7 +1109,7 @@ impl Smoketest {
10921109
/// Callers should pass `--server` explicitly when the command needs it.
10931110
pub fn spacetime_cmd_with_stdin(&self, args: &[&str], stdin_input: &str) -> Output {
10941111
let start = Instant::now();
1095-
let cli_path = ensure_binaries_built();
1112+
let cli_path = self.cli_path();
10961113
let mut child = Command::new(&cli_path)
10971114
.arg("--config-path")
10981115
.arg(&self.config_path)
@@ -1383,7 +1400,7 @@ log = "0.4"
13831400
pub fn spacetime_build(&self) -> Output {
13841401
let start = Instant::now();
13851402
let project_path = self.project_dir.path().to_str().unwrap();
1386-
let cli_path = ensure_binaries_built();
1403+
let cli_path = self.cli_path();
13871404

13881405
let mut cmd = Command::new(&cli_path);
13891406
cmd.args(["build", "--module-path", project_path])
@@ -1430,7 +1447,7 @@ log = "0.4"
14301447
// Build the WASM module from source
14311448
let project_path = self.project_dir.path().to_str().unwrap().to_string();
14321449
let build_start = Instant::now();
1433-
let cli_path = ensure_binaries_built();
1450+
let cli_path = self.cli_path();
14341451
let target_dir = shared_target_dir();
14351452

14361453
let mut build_cmd = Command::new(&cli_path);
@@ -1637,7 +1654,7 @@ log = "0.4"
16371654
///
16381655
/// This is useful for tests that need to test with multiple identities.
16391656
pub fn new_identity(&self) -> Result<()> {
1640-
let cli_path = ensure_binaries_built();
1657+
let cli_path = self.cli_path();
16411658
let config_path_str = self.config_path.to_str().unwrap();
16421659

16431660
// Logout first (ignore errors - may not be logged in)
@@ -1736,7 +1753,7 @@ log = "0.4"
17361753
) -> Result<Vec<serde_json::Value>> {
17371754
let config_path_str = self.config_path.to_str().unwrap();
17381755

1739-
let cli_path = ensure_binaries_built();
1756+
let cli_path = self.cli_path();
17401757
let mut cmd = Command::new(&cli_path);
17411758
let mut args = vec![
17421759
"--config-path".to_string(),
@@ -1786,7 +1803,7 @@ log = "0.4"
17861803
n: Option<usize>,
17871804
confirmed: Option<bool>,
17881805
) -> Result<SubscriptionHandle> {
1789-
let cli_path = ensure_binaries_built();
1806+
let cli_path = self.cli_path();
17901807
let mut cmd = Command::new(&cli_path);
17911808
// Use --print-initial-update so we know when subscription is established
17921809
let config_path_str = self.config_path.to_str().unwrap().to_string();

0 commit comments

Comments
 (0)