Skip to content

Commit

Permalink
feature: tests can be compiled without execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sayon committed Apr 22, 2024
1 parent bf43c6f commit a4fde26
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions compiler_tester/src/compiler_tester/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ pub struct Arguments {
/// Sets the `debug logging` option in LLVM.
#[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,
}

impl Arguments {
Expand Down
14 changes: 12 additions & 2 deletions compiler_tester/src/compiler_tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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 @@ -92,8 +93,17 @@ 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 workflow = if arguments.build_only {
Workflow::BuildOnly
} else {
Workflow::BuildAndRun
};
let compiler_tester = compiler_tester::CompilerTester::new(
summary.clone(),
filters,
debug_config.clone(),
workflow,
)?;

let binary_download_config_paths = vec![
arguments
Expand Down
22 changes: 20 additions & 2 deletions compiler_tester/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ 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 All @@ -63,6 +73,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 +110,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 +145,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 +176,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
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,7 @@ use std::{
sync::Arc,
};

use compiler_tester::{Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary};
use compiler_tester::{Buildable, EthereumTest, Mode, SolidityCompiler, SolidityMode, Summary, Workflow};
pub use solidity_adapter::{
test::function_call::parser::{
lexical::token::{
Expand Down Expand Up @@ -173,6 +173,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 a4fde26

Please sign in to comment.