From 0c6fe7e6d03b1a86697207d85eac7d409b946ade Mon Sep 17 00:00:00 2001 From: Oleksandr Deundiak Date: Fri, 31 Jan 2025 17:34:16 +0100 Subject: [PATCH] test(rust): remove async deletion --- .github/workflows/rust.yml | 1 - .../ockam_api/src/ui/terminal/notification.rs | 6 ++-- .../rust/ockam/ockam_command/src/command.rs | 36 ++++++++++--------- .../ockam/ockam_command/src/entry_point.rs | 12 +++---- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 214be73491f..a12f440cdee 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -317,7 +317,6 @@ jobs: ockam --version echo $(which ockam) echo $BATS_TEST_RETRIES - bash implementations/rust/ockam/ockam_command/tests/bats/run.sh local sudo PATH=$PATH BATS_LIB=$BATS_LIB bash implementations/rust/ockam/ockam_command/tests/bats/run.sh local_as_root env: OCKAM_DISABLE_UPGRADE_CHECK: 1 diff --git a/implementations/rust/ockam/ockam_api/src/ui/terminal/notification.rs b/implementations/rust/ockam/ockam_api/src/ui/terminal/notification.rs index 7ab4c2d014b..968151b9e56 100644 --- a/implementations/rust/ockam/ockam_api/src/ui/terminal/notification.rs +++ b/implementations/rust/ockam/ockam_api/src/ui/terminal/notification.rs @@ -94,14 +94,14 @@ impl NotificationHandler { if self.stop.load(Acquire) { // Drain the channel while let Ok(notification) = self.rx.try_recv() { - self.handle_notification(notification).await; + self.handle_notification(notification); } break; } } notification = self.rx.recv() => { if let Ok(notification) = notification { - self.handle_notification(notification).await; + self.handle_notification(notification); } // The channel was closed else { @@ -113,7 +113,7 @@ impl NotificationHandler { }); } - async fn handle_notification(&mut self, notification: Notification) { + fn handle_notification(&mut self, notification: Notification) { match notification { Notification::Message(contents) => { let _ = self.terminal.write_line(contents); diff --git a/implementations/rust/ockam/ockam_command/src/command.rs b/implementations/rust/ockam/ockam_command/src/command.rs index d79bce45e16..27cf2caaf4f 100644 --- a/implementations/rust/ockam/ockam_command/src/command.rs +++ b/implementations/rust/ockam/ockam_command/src/command.rs @@ -1,5 +1,5 @@ use crate::branding::{load_compile_time_vars, BrandingCompileEnvVars}; -use crate::command_events::{add_command_error_event, add_command_event}; +use crate::command_events::add_command_event; use crate::command_global_opts::CommandGlobalOpts; use crate::global_args::GlobalArgs; use crate::subcommand::OckamSubcommand; @@ -162,7 +162,7 @@ impl OckamCommand { } /// Run the command - pub async fn run(self, ctx: &mut Context, arguments: &[String]) -> miette::Result<()> { + pub async fn run(self, _ctx: &Context, arguments: &[String]) -> miette::Result<()> { // If test_argument_parser is true, command arguments are checked // but the command is not executed. This is useful to test arguments // without having to execute their logic. @@ -261,27 +261,29 @@ impl OckamCommand { .write_line(fmt_warn!("Failed to check for upgrade"))?; } - let result = self - .run_command(ctx, options.clone(), &command_name, arguments) - .with_context(cx) - .await; - - if let Err(ref e) = result { - add_command_error_event( - options.state.clone(), - &command_name, - &format!("{e}"), - arguments.join(" "), - ) - .await?; - }; + // let result = self + // .run_command(ctx, options.clone(), &command_name, arguments) + // .with_context(cx) + // .await; + // + // if let Err(ref e) = result { + // add_command_error_event( + // options.state.clone(), + // &command_name, + // &format!("{e}"), + // arguments.join(" "), + // ) + // .await?; + // }; if let Some(tracing_guard) = tracing_guard { tracing_guard.force_flush().await; tracing_guard.shutdown().await; }; - result + // result + + Ok(()) } #[instrument(skip_all, fields(command = self.subcommand.name()))] diff --git a/implementations/rust/ockam/ockam_command/src/entry_point.rs b/implementations/rust/ockam/ockam_command/src/entry_point.rs index 086c9c08083..91f3632c9aa 100644 --- a/implementations/rust/ockam/ockam_command/src/entry_point.rs +++ b/implementations/rust/ockam/ockam_command/src/entry_point.rs @@ -45,17 +45,17 @@ pub fn run() -> miette::Result<()> { let node_builder = NodeBuilder::new().no_logging(); - let (mut ctx, mut executor) = node_builder.build(); + let (ctx, mut executor) = node_builder.build(); executor.execute(async move { - match command_res { - Ok(command) => command.run(&mut ctx, &input).await?, - Err(err) => handle_invalid_command(&input, err).await?, - } + let res = match command_res { + Ok(command) => command.run(&ctx, &input).await, + Err(err) => handle_invalid_command(&input, err).await, + }; ctx.shutdown_node().await?; - Ok::<(), miette::Error>(()) + res })??; Ok(())