mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-25 10:28:00 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce3aaf1888 | |||
| 429f2e92a2 |
+1
-1
@@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://github.com/paritytech/revive-differential-testing.git"
|
repository = "https://github.com/paritytech/revive-differential-testing.git"
|
||||||
rust-version = "1.85.0"
|
rust-version = "1.88.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
revive-dt-common = { version = "0.1.0", path = "crates/common" }
|
revive-dt-common = { version = "0.1.0", path = "crates/common" }
|
||||||
|
|||||||
@@ -101,12 +101,30 @@ where
|
|||||||
anyhow::bail!("unsupported solc version: {:?}", &mode.solc_version);
|
anyhow::bail!("unsupported solc version: {:?}", &mode.solc_version);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Note: if the metadata is contained within a solidity file then this is the only file that
|
||||||
|
// we wish to compile since this is a self-contained test. Otherwise, if it's a JSON file
|
||||||
|
// then we need to compile all of the contracts that are in the directory since imports are
|
||||||
|
// allowed in there.
|
||||||
|
let Some(ref metadata_file_path) = metadata.file_path else {
|
||||||
|
anyhow::bail!("The metadata file path is not defined");
|
||||||
|
};
|
||||||
|
let mut files_to_compile = if metadata_file_path
|
||||||
|
.extension()
|
||||||
|
.is_some_and(|extension| extension.eq_ignore_ascii_case("sol"))
|
||||||
|
{
|
||||||
|
Box::new(std::iter::once(metadata_file_path.clone())) as Box<dyn Iterator<Item = _>>
|
||||||
|
} else {
|
||||||
|
Box::new(
|
||||||
|
FilesWithExtensionIterator::new(metadata.directory()?)
|
||||||
|
.with_allowed_extension("sol"),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let compiler = Compiler::<T::Compiler>::new()
|
let compiler = Compiler::<T::Compiler>::new()
|
||||||
.allow_path(metadata.directory()?)
|
.allow_path(metadata.directory()?)
|
||||||
.solc_optimizer(mode.solc_optimize());
|
.solc_optimizer(mode.solc_optimize());
|
||||||
let mut compiler = FilesWithExtensionIterator::new(metadata.directory()?)
|
let mut compiler =
|
||||||
.with_allowed_extension("sol")
|
files_to_compile.try_fold(compiler, |compiler, path| compiler.with_source(&path))?;
|
||||||
.try_fold(compiler, |compiler, path| compiler.with_source(&path))?;
|
|
||||||
for (library_instance, (library_address, _)) in self.deployed_libraries.iter() {
|
for (library_instance, (library_address, _)) in self.deployed_libraries.iter() {
|
||||||
let library_ident = &metadata
|
let library_ident = &metadata
|
||||||
.contracts
|
.contracts
|
||||||
|
|||||||
+11
-14
@@ -28,13 +28,19 @@ impl Corpus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Recursively walks `path` and parses any JSON or Solidity file into a test
|
/// If `path` is a file, try to parse it directly into a [MetadataFile].
|
||||||
/// definition [Metadata].
|
/// Else, recursively walk through the `path` directory and parse any
|
||||||
|
/// JSON or Solidity file into a test definition [MetadataFile].
|
||||||
///
|
///
|
||||||
/// Found tests are inserted into `tests`.
|
/// Found tests are inserted into `tests`.
|
||||||
///
|
|
||||||
/// `path` is expected to be a directory.
|
|
||||||
pub fn collect_metadata(path: &Path, tests: &mut Vec<MetadataFile>) {
|
pub fn collect_metadata(path: &Path, tests: &mut Vec<MetadataFile>) {
|
||||||
|
if path.is_file()
|
||||||
|
&& let Some(metadata) = MetadataFile::try_from_file(&path)
|
||||||
|
{
|
||||||
|
tests.push(metadata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let dir_entry = match std::fs::read_dir(path) {
|
let dir_entry = match std::fs::read_dir(path) {
|
||||||
Ok(dir_entry) => dir_entry,
|
Ok(dir_entry) => dir_entry,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
@@ -53,15 +59,6 @@ pub fn collect_metadata(path: &Path, tests: &mut Vec<MetadataFile>) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.is_dir() {
|
collect_metadata(&path, tests);
|
||||||
collect_metadata(&path, tests);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if path.is_file() {
|
|
||||||
if let Some(metadata) = MetadataFile::try_from_file(&path) {
|
|
||||||
tests.push(metadata)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ impl Metadata {
|
|||||||
metadata.file_path = Some(path.to_path_buf());
|
metadata.file_path = Some(path.to_path_buf());
|
||||||
metadata.contracts = Some(
|
metadata.contracts = Some(
|
||||||
[(
|
[(
|
||||||
ContractInstance::new("test"),
|
ContractInstance::new("Test"),
|
||||||
ContractPathAndIdent {
|
ContractPathAndIdent {
|
||||||
contract_source_path: path.to_path_buf(),
|
contract_source_path: path.to_path_buf(),
|
||||||
contract_ident: ContractIdent::new("Test"),
|
contract_ident: ContractIdent::new("Test"),
|
||||||
|
|||||||
Reference in New Issue
Block a user