Skip to content

Commit

Permalink
Extract workflow and improve argument parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
sayon committed Apr 22, 2024
1 parent a4fde26 commit 8fc7c39
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
8 changes: 5 additions & 3 deletions compiler_tester/src/compiler_tester/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::path::PathBuf;

use structopt::StructOpt;

use compiler_tester::workflow::Workflow;

///
/// The compiler tester arguments.
///
Expand Down Expand Up @@ -104,9 +106,9 @@ pub struct Arguments {
#[structopt(long = "llvm-debug-logging")]
pub llvm_debug_logging: bool,

/// Builds the test code but does not run tests.
#[structopt(long = "build-only")]
pub build_only: bool,
/// Choose between `build` to compile tests only without running them, and `run` to compile and run them.
#[structopt(long = "workflow", default_value = "run")]
pub workflow: Workflow,
}

impl Arguments {
Expand Down
8 changes: 1 addition & 7 deletions compiler_tester/src/compiler_tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::time::Instant;
use colored::Colorize;

use self::arguments::Arguments;
use compiler_tester::Workflow;

/// The rayon worker stack size.
const RAYON_WORKER_STACK_SIZE: usize = 16 * 1024 * 1024;
Expand Down Expand Up @@ -93,16 +92,11 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> {

let filters = compiler_tester::Filters::new(arguments.paths, arguments.modes, arguments.groups);

let workflow = if arguments.build_only {
Workflow::BuildOnly
} else {
Workflow::BuildAndRun
};
let compiler_tester = compiler_tester::CompilerTester::new(
summary.clone(),
filters,
debug_config.clone(),
workflow,
arguments.workflow,
)?;

let binary_download_config_paths = vec![
Expand Down
12 changes: 2 additions & 10 deletions compiler_tester/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub(crate) mod summary;
pub(crate) mod test;
pub(crate) mod utils;
pub(crate) mod vm;
pub mod workflow;

pub use self::filters::Filters;
pub use self::llvm_options::LLVMOptions;
Expand All @@ -26,6 +27,7 @@ use std::sync::Mutex;
use itertools::Itertools;
use rayon::iter::IntoParallelIterator;
use rayon::iter::ParallelIterator;
use workflow::Workflow;

pub use crate::compilers::eravm::EraVMCompiler;
pub use crate::compilers::llvm::LLVMCompiler;
Expand Down Expand Up @@ -53,16 +55,6 @@ pub const TRACE_DIRECTORY: &str = "./trace/";
///
type Test = (Arc<dyn Buildable>, Arc<dyn Compiler>, Mode);

///
/// Describes sets of actions that compiler tester is able to perform.
///
pub enum Workflow {
/// Only build tests but not execute them.
BuildOnly,
/// Build and execute tests.
BuildAndRun,
}

///
/// The compiler tester.
///
Expand Down
29 changes: 29 additions & 0 deletions compiler_tester/src/workflow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//!
//! Compiler tester workflows
//!
///
/// Describes sets of actions that compiler tester is able to perform.
///
#[derive(Debug)]
pub enum Workflow {
/// Only build tests but not execute them.
BuildOnly,
/// Build and execute tests.
BuildAndRun,
}
use std::str::FromStr;

// any error type implementing Display is acceptable.
type ParseError = &'static str;

impl FromStr for Workflow {
type Err = ParseError;
fn from_str(day: &str) -> Result<Self, Self::Err> {
match day {
"build" => Ok(Workflow::BuildOnly),
"run" => Ok(Workflow::BuildAndRun),
_ => Err("Could not parse workflow. Supported workflows: build, run."),
}
}
}
3 changes: 2 additions & 1 deletion fuzzer/fuzz_targets/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::{
sync::Arc,
};

use compiler_tester::{Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary, Workflow};
use compiler_tester::{Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary};
use compiler_tester::workflow::Workflow;
pub use solidity_adapter::{
test::function_call::parser::{
lexical::token::{
Expand Down

0 comments on commit 8fc7c39

Please sign in to comment.