Skip to content

Commit

Permalink
feat: compiling tests without executing them (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Oleksandr Zarudnyi <[email protected]>
  • Loading branch information
sayon and hedgar2017 authored Apr 23, 2024
1 parent bf43c6f commit 7c85964
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
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;

///
/// 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,10 +10,12 @@ pub(crate) mod summary;
pub(crate) mod test;
pub(crate) mod utils;
pub(crate) mod vm;
pub(crate) mod workflow;

pub use self::filters::Filters;
pub use self::llvm_options::LLVMOptions;
pub use self::summary::Summary;
pub use self::workflow::Workflow;
pub use crate::vm::eravm::deployers::native_deployer::NativeDeployer as EraVMNativeDeployer;
pub use crate::vm::eravm::deployers::system_contract_deployer::SystemContractDeployer as EraVMSystemContractDeployer;
pub use crate::vm::eravm::EraVM;
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
28 changes: 28 additions & 0 deletions compiler_tester/src/workflow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//!
//! The compiler tester workflows.
//!
use std::str::FromStr;

///
/// 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,
}

impl FromStr for Workflow {
type Err = &'static str;

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 @@ -3,6 +3,7 @@ use std::{
sync::Arc,
};

use compiler_tester::Workflow;
use compiler_tester::{Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary};
pub use solidity_adapter::{
test::function_call::parser::{
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

0 comments on commit 7c85964

Please sign in to comment.