Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sequencer_node): compile the node, not the entire project #2265

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
Loading