diff --git a/crates/starknet_sequencer_node/src/test_utils/compilation.rs b/crates/starknet_sequencer_node/src/test_utils/compilation.rs index 645fe536ae..c89d62d397 100644 --- a/crates/starknet_sequencer_node/src/test_utils/compilation.rs +++ b/crates/starknet_sequencer_node/src/test_utils/compilation.rs @@ -1,6 +1,7 @@ -use std::process::{Command, ExitStatus, Stdio}; -use std::{env, io}; +use std::io; +use std::process::{ExitStatus, Stdio}; +use infra_utils::command::create_shell_command; use tracing::info; #[cfg(test)] @@ -16,26 +17,26 @@ pub enum NodeCompilationError { } /// Compiles the node using `cargo build` for testing purposes. -fn compile_node() -> io::Result { - info!("Compiling the project"); - // Get the current working directory for the project - let project_path = env::current_dir().expect("Failed to get current directory"); +async fn compile_node() -> io::Result { + info!("Compiling the starknet_sequencer_node binary"); // Run `cargo build` to compile the project - let compilation_result = Command::new("cargo") + let compilation_result = create_shell_command("cargo") .arg("build") - .current_dir(&project_path) + .arg("--bin") + .arg("starknet_sequencer_node") .arg("--quiet") .stderr(Stdio::inherit()) .stdout(Stdio::inherit()) - .status(); + .status() + .await?; info!("Compilation result: {:?}", compilation_result); - compilation_result + Ok(compilation_result) } -pub fn compile_node_result() -> Result<(), NodeCompilationError> { - match compile_node() { +pub async fn compile_node_result() -> Result<(), NodeCompilationError> { + match compile_node().await { Ok(status) if status.success() => Ok(()), Ok(status) => Err(NodeCompilationError::Status(status)), Err(e) => Err(NodeCompilationError::IO(e)), diff --git a/crates/starknet_sequencer_node/src/test_utils/compilation_test.rs b/crates/starknet_sequencer_node/src/test_utils/compilation_test.rs index 3dd888fbba..3e2f6b6200 100644 --- a/crates/starknet_sequencer_node/src/test_utils/compilation_test.rs +++ b/crates/starknet_sequencer_node/src/test_utils/compilation_test.rs @@ -1,6 +1,9 @@ +use rstest::rstest; + use crate::test_utils::compilation::compile_node_result; -#[test] -fn test_compile_node() { - assert!(compile_node_result().is_ok(), "Compilation failed"); +#[rstest] +#[tokio::test] +async fn test_compile_node() { + assert!(compile_node_result().await.is_ok(), "Compilation failed"); }