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

feat: compiling tests without executing them #13

Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 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 @@ -103,6 +105,10 @@ pub struct Arguments {
/// Sets the `debug logging` option in LLVM.
#[structopt(long = "llvm-debug-logging")]
pub llvm_debug_logging: 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: 6 additions & 2 deletions compiler_tester/src/compiler_tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> {

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

let compiler_tester =
compiler_tester::CompilerTester::new(summary.clone(), filters, debug_config.clone())?;
let compiler_tester = compiler_tester::CompilerTester::new(
summary.clone(),
filters,
debug_config.clone(),
arguments.workflow,
)?;

let binary_download_config_paths = vec![
arguments
Expand Down
14 changes: 12 additions & 2 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 @@ -63,6 +65,8 @@ pub struct CompilerTester {
pub filters: Filters,
/// The debug config.
pub debug_config: Option<era_compiler_llvm_context::DebugConfig>,
/// Actions to perform.
pub workflow: Workflow,
}

impl CompilerTester {
Expand Down Expand Up @@ -98,11 +102,13 @@ impl CompilerTester {
summary: Arc<Mutex<Summary>>,
filters: Filters,
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
workflow: Workflow,
) -> anyhow::Result<Self> {
Ok(Self {
summary,
filters,
debug_config,
workflow,
})
}

Expand Down Expand Up @@ -131,7 +137,9 @@ impl CompilerTester {
&self.filters,
specialized_debug_config,
) {
test.run::<D, M>(self.summary.clone(), vm.clone());
if let Workflow::BuildAndRun = self.workflow {
test.run::<D, M>(self.summary.clone(), vm.clone())
};
}
})
.collect();
Expand Down Expand Up @@ -160,7 +168,9 @@ impl CompilerTester {
&self.filters,
specialized_debug_config,
) {
test.run(self.summary.clone());
if let Workflow::BuildAndRun = self.workflow {
test.run(self.summary.clone())
};
}
})
.collect();
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."),
}
}
}
2 changes: 2 additions & 0 deletions fuzzer/fuzz_targets/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
};

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 Expand Up @@ -173,6 +174,7 @@ pub fn build_and_run(test: EthereumTest) -> anyhow::Result<Summary> {
compiler_tester::Summary::new(true, false).wrap(),
compiler_tester::Filters::new(vec![], vec![], vec![]),
None,
Workflow::BuildAndRun
)?;
zkevm_tester::runners::compiler_tests::set_tracing_mode(
zkevm_tester::runners::compiler_tests::VmTracingOptions::from_u64(0),
Expand Down
Loading