Skip to content

Commit

Permalink
chore(sequencer_node): compile the node, not the entire project
Browse files Browse the repository at this point in the history
commit-id:7f25ebe8
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 25, 2024
1 parent aa0115b commit beb89d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
25 changes: 13 additions & 12 deletions crates/starknet_sequencer_node/src/test_utils/compilation.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -16,26 +17,26 @@ pub enum NodeCompilationError {
}

/// Compiles the node using `cargo build` for testing purposes.
fn compile_node() -> io::Result<ExitStatus> {
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<ExitStatus> {
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)),
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit beb89d3

Please sign in to comment.