mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-30 03:37:59 +00:00
Implement basic reporting facility (#18)
* wip Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * save to file after all tasks done Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * error out early if the workdir does not exist Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * the compiler statistics Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * allow compiler statistics per implementation Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * save compiler problems Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * add flag whether to extract compiler errors Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * whitespace Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
+25
-24
@@ -10,6 +10,7 @@ use revive_dt_core::{
|
||||
};
|
||||
use revive_dt_format::{corpus::Corpus, metadata::Metadata};
|
||||
use revive_dt_node::pool::NodePool;
|
||||
use revive_dt_report::reporter::{Report, Span};
|
||||
use temp_dir::TempDir;
|
||||
|
||||
static TEMP_DIR: LazyLock<TempDir> = LazyLock::new(|| TempDir::new().unwrap());
|
||||
@@ -17,18 +18,15 @@ static TEMP_DIR: LazyLock<TempDir> = LazyLock::new(|| TempDir::new().unwrap());
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let args = init_cli()?;
|
||||
|
||||
let corpora = collect_corpora(&args)?;
|
||||
for (corpus, tests) in collect_corpora(&args)? {
|
||||
let span = Span::new(corpus, args.clone())?;
|
||||
|
||||
if let Some(platform) = &args.compile_only {
|
||||
for tests in corpora.values() {
|
||||
main_compile_only(&args, tests, platform)?;
|
||||
match &args.compile_only {
|
||||
Some(platform) => compile_corpus(&args, &tests, platform, span),
|
||||
None => execute_corpus(&args, &tests, span)?,
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for tests in corpora.values() {
|
||||
main_execute_differential(&args, tests)?;
|
||||
Report::save()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -38,17 +36,26 @@ fn init_cli() -> anyhow::Result<Arguments> {
|
||||
env_logger::init();
|
||||
|
||||
let mut args = Arguments::parse();
|
||||
|
||||
if args.corpus.is_empty() {
|
||||
anyhow::bail!("no test corpus specified");
|
||||
}
|
||||
if args.working_directory.is_none() {
|
||||
args.temp_dir = Some(&TEMP_DIR);
|
||||
|
||||
match args.working_directory.as_ref() {
|
||||
Some(dir) => {
|
||||
if !dir.exists() {
|
||||
anyhow::bail!("workdir {} does not exist", dir.display());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
args.temp_dir = Some(&TEMP_DIR);
|
||||
}
|
||||
}
|
||||
log::info!("workdir: {}", args.directory().display());
|
||||
|
||||
ThreadPoolBuilder::new()
|
||||
.num_threads(args.workers)
|
||||
.build_global()
|
||||
.unwrap();
|
||||
.build_global()?;
|
||||
|
||||
Ok(args)
|
||||
}
|
||||
@@ -67,7 +74,7 @@ fn collect_corpora(args: &Arguments) -> anyhow::Result<HashMap<Corpus, Vec<Metad
|
||||
Ok(corpora)
|
||||
}
|
||||
|
||||
fn main_execute_differential(args: &Arguments, tests: &[Metadata]) -> anyhow::Result<()> {
|
||||
fn execute_corpus(args: &Arguments, tests: &[Metadata], span: Span) -> anyhow::Result<()> {
|
||||
let leader_nodes = NodePool::new(args)?;
|
||||
let follower_nodes = NodePool::new(args)?;
|
||||
|
||||
@@ -82,7 +89,7 @@ fn main_execute_differential(args: &Arguments, tests: &[Metadata]) -> anyhow::Re
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
|
||||
match driver.execute() {
|
||||
match driver.execute(span) {
|
||||
Ok(build) => {
|
||||
log::info!(
|
||||
"metadata {} success",
|
||||
@@ -102,25 +109,19 @@ fn main_execute_differential(args: &Arguments, tests: &[Metadata]) -> anyhow::Re
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main_compile_only(
|
||||
config: &Arguments,
|
||||
tests: &[Metadata],
|
||||
platform: &TestingPlatform,
|
||||
) -> anyhow::Result<()> {
|
||||
fn compile_corpus(config: &Arguments, tests: &[Metadata], platform: &TestingPlatform, span: Span) {
|
||||
tests.par_iter().for_each(|metadata| {
|
||||
for mode in &metadata.solc_modes() {
|
||||
match platform {
|
||||
TestingPlatform::Geth => {
|
||||
let mut state = State::<Geth>::new(config);
|
||||
let mut state = State::<Geth>::new(config, span);
|
||||
let _ = state.build_contracts(mode, metadata);
|
||||
}
|
||||
TestingPlatform::Kitchensink => {
|
||||
let mut state = State::<Kitchensink>::new(config);
|
||||
let mut state = State::<Kitchensink>::new(config, span);
|
||||
let _ = state.build_contracts(mode, metadata);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user