mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-05-08 10:47:58 +00:00
add dev account to config
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -19,31 +19,21 @@ pub struct SolcSettings {
|
||||
pub fn build_evm(
|
||||
metadata: &Metadata,
|
||||
) -> anyhow::Result<HashMap<SolcSettings, SolcStandardJsonOutput>> {
|
||||
let Some(metadata_path) = &metadata.path else {
|
||||
anyhow::bail!("missing directory in metadata");
|
||||
};
|
||||
let Some(directory) = metadata_path.parent() else {
|
||||
anyhow::bail!("metadata path has no parent: {}", metadata_path.display());
|
||||
};
|
||||
let Some(contracts) = &metadata.contracts else {
|
||||
anyhow::bail!("missing contracts in metadata: {}", metadata_path.display());
|
||||
};
|
||||
let sources = metadata.contract_sources()?;
|
||||
let base_path = metadata.directory()?.display().to_string();
|
||||
let modes = metadata
|
||||
.modes
|
||||
.to_owned()
|
||||
.unwrap_or_else(|| vec![Mode::Solidity(Default::default())]);
|
||||
|
||||
let sources = super::contract_sources_from_metadata(directory, contracts)?;
|
||||
|
||||
let mut result = HashMap::new();
|
||||
for mode in modes {
|
||||
let mut compiler = Compiler::<Solc>::new().base_path(directory.display().to_string());
|
||||
for file in sources.values() {
|
||||
let mut compiler = Compiler::<Solc>::new().base_path(base_path.clone());
|
||||
for (file, _contract) in sources.values() {
|
||||
compiler = compiler.with_source(file)?;
|
||||
}
|
||||
|
||||
match mode {
|
||||
Mode::Unknown(mode) => log::debug!("compiler: ignoring unknown mode '{mode}'"),
|
||||
Mode::Solidity(SolcMode {
|
||||
solc_version: _,
|
||||
solc_optimize,
|
||||
@@ -61,6 +51,7 @@ pub fn build_evm(
|
||||
out,
|
||||
);
|
||||
}
|
||||
Mode::Unknown(mode) => log::debug!("compiler: ignoring unknown mode '{mode}'"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,4 @@
|
||||
//! The test driver handles the compilation and execution of the test cases.
|
||||
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
pub mod compiler;
|
||||
pub mod input;
|
||||
|
||||
pub(crate) fn contract_sources_from_metadata(
|
||||
directory: &Path,
|
||||
contracts: &BTreeMap<String, String>,
|
||||
) -> anyhow::Result<BTreeMap<String, PathBuf>> {
|
||||
let mut sources = BTreeMap::new();
|
||||
for (name, contract) in contracts {
|
||||
// TODO: broken if a colon is in the dir name..
|
||||
let Some(solidity_file_name) = contract.split(':').next() else {
|
||||
anyhow::bail!("metadata contains invalid contract: {contract}");
|
||||
};
|
||||
|
||||
let mut file = directory.to_path_buf();
|
||||
file.push(solidity_file_name);
|
||||
sources.insert(name.clone(), file);
|
||||
}
|
||||
|
||||
Ok(sources)
|
||||
}
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
//!
|
||||
//! This crate defines the testing configuration and
|
||||
//! provides a helper utilty to execute tests.
|
||||
//!
|
||||
//!
|
||||
|
||||
pub mod driver;
|
||||
|
||||
+23
-21
@@ -11,18 +11,14 @@ use temp_dir::TempDir;
|
||||
fn main() -> anyhow::Result<()> {
|
||||
env_logger::init();
|
||||
|
||||
let mut config = Arguments::parse();
|
||||
|
||||
if config.corpus.is_empty() {
|
||||
let mut args = Arguments::parse();
|
||||
if args.corpus.is_empty() {
|
||||
anyhow::bail!("no test corpus specified");
|
||||
}
|
||||
let temp_dir = TempDir::new()?;
|
||||
args.working_directory.get_or_insert(temp_dir.path().into());
|
||||
|
||||
let temporary_directory = TempDir::new()?;
|
||||
config
|
||||
.working_directory
|
||||
.get_or_insert_with(|| temporary_directory.path().into());
|
||||
|
||||
for path in config.corpus.iter().collect::<BTreeSet<_>>() {
|
||||
for path in args.corpus.iter().collect::<BTreeSet<_>>() {
|
||||
log::trace!("attempting corpus {path:?}");
|
||||
let corpus = Corpus::try_from_path(path)?;
|
||||
log::info!("found corpus: {corpus:?}");
|
||||
@@ -30,18 +26,24 @@ fn main() -> anyhow::Result<()> {
|
||||
let tests = corpus.enumerate_tests();
|
||||
log::info!("found {} tests", tests.len());
|
||||
|
||||
tests
|
||||
.par_iter()
|
||||
.for_each(|metadata| match build_evm(metadata) {
|
||||
Ok(_) => log::info!(
|
||||
"metadata {} compilation success",
|
||||
metadata.path.as_ref().unwrap().display()
|
||||
),
|
||||
Err(error) => log::warn!(
|
||||
"metadata {} compilation failure: {error:?}",
|
||||
metadata.path.as_ref().unwrap().display()
|
||||
),
|
||||
});
|
||||
tests.par_iter().for_each(|metadata| {
|
||||
let _ = match build_evm(metadata) {
|
||||
Ok(build) => {
|
||||
log::info!(
|
||||
"metadata {} compilation success",
|
||||
metadata.file_path.as_ref().unwrap().display()
|
||||
);
|
||||
build
|
||||
}
|
||||
Err(error) => {
|
||||
log::warn!(
|
||||
"metadata {} compilation failure: {error:?}",
|
||||
metadata.file_path.as_ref().unwrap().display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user