Skip to content

Commit bce875a

Browse files
committed
feat(replay): add cli arg to ignore build env mismatch
1 parent 8e9d582 commit bce875a

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

cli/src/commands/replay/replay_state_with_input_actions.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ pub struct ReplayStateWithInputActions {
1010
#[arg(long, default_value = "./target/release/libreplay_dynamic_effects.so")]
1111
pub dynamic_effects_lib: String,
1212

13+
#[arg(long)]
14+
pub ignore_mismatch: bool,
15+
1316
/// Verbosity level
1417
#[arg(long, short, default_value = "info")]
1518
pub verbosity: tracing::Level,
@@ -30,13 +33,22 @@ impl ReplayStateWithInputActions {
3033
}
3134
};
3235

33-
replay_state_with_input_actions(&dir, dynamic_effects_lib, check_build_env)?;
36+
replay_state_with_input_actions(
37+
&dir,
38+
dynamic_effects_lib,
39+
self.ignore_mismatch,
40+
check_build_env,
41+
)?;
3442

3543
Ok(())
3644
}
3745
}
3846

39-
pub fn check_build_env(record_env: &BuildEnv, replay_env: &BuildEnv) -> anyhow::Result<()> {
47+
pub fn check_build_env(
48+
record_env: &BuildEnv,
49+
replay_env: &BuildEnv,
50+
ignore_mismatch: bool,
51+
) -> anyhow::Result<()> {
4052
let is_git_same = record_env.git.commit_hash == replay_env.git.commit_hash;
4153
let is_cargo_same = record_env.cargo == replay_env.cargo;
4254
let is_rustc_same = record_env.rustc == replay_env.rustc;
@@ -47,7 +59,8 @@ pub fn check_build_env(record_env: &BuildEnv, replay_env: &BuildEnv) -> anyhow::
4759
record_env.git, replay_env.git
4860
);
4961
let msg = format!("git build env mismatch!\n{diff}");
50-
if console::user_attended() {
62+
if ignore_mismatch {
63+
} else if console::user_attended() {
5164
use dialoguer::Confirm;
5265

5366
let prompt = format!("{msg}\nDo you want to continue?");

node/native/src/replay.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::NodeService;
1212
pub fn replay_state_with_input_actions(
1313
dir: &str,
1414
dynamic_effects_lib: Option<String>,
15-
mut check_build_env: impl FnMut(&BuildEnv, &BuildEnv) -> anyhow::Result<()>,
15+
ignore_mismatch: bool,
16+
mut check_build_env: impl FnMut(&BuildEnv, &BuildEnv, bool) -> anyhow::Result<()>,
1617
) -> anyhow::Result<crate::Node> {
1718
eprintln!("replaying node based on initial state and actions from the dir: {dir}");
1819
let reader = StateWithInputActionsReader::new(dir);
@@ -50,7 +51,7 @@ pub fn replay_state_with_input_actions(
5051
let store = node.store_mut();
5152

5253
let replay_env = BuildEnv::get();
53-
check_build_env(&store.state().config.build, &replay_env)?;
54+
check_build_env(&store.state().config.build, &replay_env, ignore_mismatch)?;
5455

5556
eprintln!("reading actions from dir: {dir}");
5657

node/testing/src/scenarios/record_replay/block_production.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ impl RecordReplayBlockProduction {
5050
let replayed_node = replay_state_with_input_actions(
5151
recording_dir.as_os_str().to_str().unwrap(),
5252
None,
53-
|_, _| Ok(()),
53+
false,
54+
|_, _, _| Ok(()),
5455
)
5556
.expect("replay failed");
5657

node/testing/src/scenarios/record_replay/bootstrap.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ impl RecordReplayBootstrap {
5151
let replayed_node = replay_state_with_input_actions(
5252
recording_dir.as_os_str().to_str().unwrap(),
5353
None,
54-
|_, _| Ok(()),
54+
false,
55+
|_, _, _| Ok(()),
5556
)
5657
.expect("replay failed");
5758

0 commit comments

Comments
 (0)