Skip to content

Commit

Permalink
test(rust): remove async deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjoDeundiak committed Jan 31, 2025
1 parent ec66a1c commit 0c6fe7e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
1 change: 0 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ impl<T: TerminalWriter + Debug + Send + 'static> NotificationHandler<T> {
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 {
Expand All @@ -113,7 +113,7 @@ impl<T: TerminalWriter + Debug + Send + 'static> NotificationHandler<T> {
});
}

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);
Expand Down
36 changes: 19 additions & 17 deletions implementations/rust/ockam/ockam_command/src/command.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()))]
Expand Down
12 changes: 6 additions & 6 deletions implementations/rust/ockam/ockam_command/src/entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 0c6fe7e

Please sign in to comment.