Skip to content

Commit

Permalink
Merge branch 'main' into v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgar2017 committed Apr 23, 2024
2 parents bfcbe5e + 7c85964 commit 9490c91
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 52 deletions.
71 changes: 36 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ -107,6 +109,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
11 changes: 8 additions & 3 deletions compiler_tester/src/compiler_tester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,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.solc_bin_config_path.unwrap_or_else(|| {
Expand Down Expand Up @@ -208,7 +212,7 @@ fn main_inner(arguments: Arguments) -> anyhow::Result<()> {
);

if let Some(path) = arguments.benchmark {
let benchmark = summary.benchmark();
let benchmark = summary.benchmark()?;
benchmark.write_to_file(path)?;
}

Expand Down Expand Up @@ -258,6 +262,7 @@ mod tests {
system_contracts_save_path: None,
llvm_verify_each: false,
llvm_debug_logging: false,
workflow: compiler_tester::Workflow::BuildAndRun,
};

crate::main_inner(arguments).expect("Manual testing failed");
Expand Down
32 changes: 27 additions & 5 deletions compiler_tester/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) mod target;
pub(crate) mod test;
pub(crate) mod utils;
pub(crate) mod vm;
pub(crate) mod workflow;

use std::path::Path;
use std::sync::Arc;
Expand Down Expand Up @@ -46,6 +47,7 @@ pub use crate::vm::eravm::deployers::system_contract_deployer::SystemContractDep
pub use crate::vm::eravm::deployers::EraVMDeployer;
pub use crate::vm::eravm::EraVM;
pub use crate::vm::evm::EVM;
pub use crate::workflow::Workflow;

/// The debug directory path.
pub const DEBUG_DIRECTORY: &str = "./debug/";
Expand All @@ -68,6 +70,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 @@ -103,11 +107,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 All @@ -124,15 +130,22 @@ impl CompilerTester {
let _: Vec<()> = tests
.into_par_iter()
.map(|(test, compiler, mode)| {
let mode_string = mode.to_string();
let specialized_debug_config = self
.debug_config
.as_ref()
.and_then(|config| config.create_subdirectory(mode_string.as_str()).ok());
if let Some(test) = test.build_for_eravm(
mode,
compiler,
Target::EraVM,
self.summary.clone(),
&self.filters,
self.debug_config.clone(),
specialized_debug_config,
) {
test.run_eravm::<D, M>(self.summary.clone(), vm.clone());
if let Workflow::BuildAndRun = self.workflow {
test.run_eravm::<D, M>(self.summary.clone(), vm.clone())
};
}
})
.collect();
Expand All @@ -149,15 +162,22 @@ impl CompilerTester {
let _: Vec<()> = tests
.into_par_iter()
.map(|(test, compiler, mode)| {
let mode_string = mode.to_string();
let specialized_debug_config = self
.debug_config
.as_ref()
.and_then(|config| config.create_subdirectory(mode_string.as_str()).ok());
if let Some(test) = test.build_for_evm(
mode,
compiler,
Target::EVM,
self.summary.clone(),
&self.filters,
self.debug_config.clone(),
specialized_debug_config,
) {
test.run_evm(self.summary.clone());
if let Workflow::BuildAndRun = self.workflow {
test.run_evm(self.summary.clone())
};
}
})
.collect();
Expand Down Expand Up @@ -190,7 +210,9 @@ impl CompilerTester {
&self.filters,
self.debug_config.clone(),
) {
test.run_evm_interpreter::<D, M>(self.summary.clone(), vm.clone());
if let Workflow::BuildAndRun = self.workflow {
test.run_evm_interpreter::<D, M>(self.summary.clone(), vm.clone());
}
}
})
.collect();
Expand Down
Loading

0 comments on commit 9490c91

Please sign in to comment.