mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-20 20:51:05 +00:00
Address nits
This commit is contained in:
Generated
+1
@@ -4044,6 +4044,7 @@ dependencies = [
|
|||||||
"revive-common",
|
"revive-common",
|
||||||
"revive-dt-common",
|
"revive-dt-common",
|
||||||
"revive-dt-config",
|
"revive-dt-config",
|
||||||
|
"revive-dt-format",
|
||||||
"revive-dt-solc-binaries",
|
"revive-dt-solc-binaries",
|
||||||
"revive-solc-json-interface",
|
"revive-solc-json-interface",
|
||||||
"semver 1.0.26",
|
"semver 1.0.26",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ rust-version.workspace = true
|
|||||||
revive-solc-json-interface = { workspace = true }
|
revive-solc-json-interface = { workspace = true }
|
||||||
revive-dt-common = { workspace = true }
|
revive-dt-common = { workspace = true }
|
||||||
revive-dt-config = { workspace = true }
|
revive-dt-config = { workspace = true }
|
||||||
|
revive-dt-format = { workspace = true }
|
||||||
revive-dt-solc-binaries = { workspace = true }
|
revive-dt-solc-binaries = { workspace = true }
|
||||||
revive-common = { workspace = true }
|
revive-common = { workspace = true }
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ use revive_common::EVMVersion;
|
|||||||
use revive_dt_common::types::VersionOrRequirement;
|
use revive_dt_common::types::VersionOrRequirement;
|
||||||
use revive_dt_config::Arguments;
|
use revive_dt_config::Arguments;
|
||||||
|
|
||||||
|
// Re-export this as it's a part of the compiler interface.
|
||||||
|
pub use revive_dt_format::mode::ModeOptimizerSetting;
|
||||||
|
|
||||||
pub mod revive_js;
|
pub mod revive_js;
|
||||||
pub mod revive_resolc;
|
pub mod revive_resolc;
|
||||||
pub mod solc;
|
pub mod solc;
|
||||||
@@ -48,7 +51,7 @@ pub trait SolidityCompiler {
|
|||||||
/// The generic compilation input configuration.
|
/// The generic compilation input configuration.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct CompilerInput {
|
pub struct CompilerInput {
|
||||||
pub enable_optimization: Option<bool>,
|
pub optimization: Option<ModeOptimizerSetting>,
|
||||||
pub via_ir: Option<bool>,
|
pub via_ir: Option<bool>,
|
||||||
pub evm_version: Option<EVMVersion>,
|
pub evm_version: Option<EVMVersion>,
|
||||||
pub allow_paths: Vec<PathBuf>,
|
pub allow_paths: Vec<PathBuf>,
|
||||||
@@ -84,7 +87,7 @@ where
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
input: CompilerInput {
|
input: CompilerInput {
|
||||||
enable_optimization: Default::default(),
|
optimization: Default::default(),
|
||||||
via_ir: Default::default(),
|
via_ir: Default::default(),
|
||||||
evm_version: Default::default(),
|
evm_version: Default::default(),
|
||||||
allow_paths: Default::default(),
|
allow_paths: Default::default(),
|
||||||
@@ -96,8 +99,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_optimization(mut self, value: impl Into<Option<bool>>) -> Self {
|
pub fn with_optimization(mut self, value: impl Into<Option<ModeOptimizerSetting>>) -> Self {
|
||||||
self.input.enable_optimization = value.into();
|
self.input.optimization = value.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use revive_solc_json_interface::{
|
|||||||
SolcStandardJsonOutput,
|
SolcStandardJsonOutput,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{CompilerInput, CompilerOutput, SolidityCompiler};
|
use crate::{CompilerInput, CompilerOutput, ModeOptimizerSetting, SolidityCompiler};
|
||||||
|
|
||||||
use alloy::json_abi::JsonAbi;
|
use alloy::json_abi::JsonAbi;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
@@ -39,7 +39,7 @@ impl SolidityCompiler for Resolc {
|
|||||||
async fn build(
|
async fn build(
|
||||||
&self,
|
&self,
|
||||||
CompilerInput {
|
CompilerInput {
|
||||||
enable_optimization,
|
optimization,
|
||||||
// Ignored and not honored since this is required for the resolc compilation.
|
// Ignored and not honored since this is required for the resolc compilation.
|
||||||
via_ir: _via_ir,
|
via_ir: _via_ir,
|
||||||
evm_version,
|
evm_version,
|
||||||
@@ -78,7 +78,9 @@ impl SolidityCompiler for Resolc {
|
|||||||
output_selection: Some(SolcStandardJsonInputSettingsSelection::new_required()),
|
output_selection: Some(SolcStandardJsonInputSettingsSelection::new_required()),
|
||||||
via_ir: Some(true),
|
via_ir: Some(true),
|
||||||
optimizer: SolcStandardJsonInputSettingsOptimizer::new(
|
optimizer: SolcStandardJsonInputSettingsOptimizer::new(
|
||||||
enable_optimization.unwrap_or(false),
|
optimization
|
||||||
|
.unwrap_or(ModeOptimizerSetting::M0)
|
||||||
|
.optimizations_enabled(),
|
||||||
None,
|
None,
|
||||||
&Version::new(0, 0, 0),
|
&Version::new(0, 0, 0),
|
||||||
false,
|
false,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ impl SolidityCompiler for Solc {
|
|||||||
async fn build(
|
async fn build(
|
||||||
&self,
|
&self,
|
||||||
CompilerInput {
|
CompilerInput {
|
||||||
enable_optimization,
|
optimization,
|
||||||
via_ir,
|
via_ir,
|
||||||
evm_version,
|
evm_version,
|
||||||
allow_paths,
|
allow_paths,
|
||||||
@@ -55,7 +55,7 @@ impl SolidityCompiler for Solc {
|
|||||||
),
|
),
|
||||||
settings: Settings {
|
settings: Settings {
|
||||||
optimizer: Optimizer {
|
optimizer: Optimizer {
|
||||||
enabled: enable_optimization,
|
enabled: optimization.map(|o| o.optimizations_enabled()),
|
||||||
details: Some(Default::default()),
|
details: Some(Default::default()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ use revive_dt_format::{
|
|||||||
corpus::Corpus,
|
corpus::Corpus,
|
||||||
input::Input,
|
input::Input,
|
||||||
metadata::{ContractInstance, ContractPathAndIdent, Metadata, MetadataFile},
|
metadata::{ContractInstance, ContractPathAndIdent, Metadata, MetadataFile},
|
||||||
mode::{Mode, ModeOptimizerSetting, ModePipeline},
|
mode::Mode,
|
||||||
};
|
};
|
||||||
use revive_dt_node::pool::NodePool;
|
use revive_dt_node::pool::NodePool;
|
||||||
use revive_dt_report::reporter::{Report, Span};
|
use revive_dt_report::reporter::{Report, Span};
|
||||||
@@ -661,8 +661,8 @@ async fn compile_contracts<P: Platform>(
|
|||||||
|
|
||||||
let compiler = Compiler::<P::Compiler>::new()
|
let compiler = Compiler::<P::Compiler>::new()
|
||||||
.with_allow_path(metadata.directory()?)
|
.with_allow_path(metadata.directory()?)
|
||||||
.with_optimization(mode.optimize_setting != ModeOptimizerSetting::M0)
|
.with_optimization(mode.optimize_setting)
|
||||||
.with_via_ir(mode.pipeline == ModePipeline::Y);
|
.with_via_ir(mode.via_yul_ir());
|
||||||
let mut compiler = metadata
|
let mut compiler = metadata
|
||||||
.files_to_compile()?
|
.files_to_compile()?
|
||||||
.try_fold(compiler, |compiler, path| compiler.with_source(&path))?;
|
.try_fold(compiler, |compiler, path| compiler.with_source(&path))?;
|
||||||
|
|||||||
+29
-26
@@ -1,7 +1,6 @@
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use revive_dt_common::types::VersionOrRequirement;
|
use revive_dt_common::types::VersionOrRequirement;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use serde::de::Deserializer;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
@@ -11,10 +10,10 @@ use std::sync::LazyLock;
|
|||||||
/// This represents a mode that a given test should be run with, if possible.
|
/// This represents a mode that a given test should be run with, if possible.
|
||||||
///
|
///
|
||||||
/// We obtain this by taking a [`ParsedMode`], which may be looser or more strict
|
/// We obtain this by taking a [`ParsedMode`], which may be looser or more strict
|
||||||
/// in its requirements, and then expanding it out into a list of [`TestMode`]s.
|
/// in its requirements, and then expanding it out into a list of [`Mode`]s.
|
||||||
///
|
///
|
||||||
/// Use [`ParsedMode::to_test_modes()`] to do this.
|
/// Use [`ParsedMode::to_test_modes()`] to do this.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
|
||||||
pub struct Mode {
|
pub struct Mode {
|
||||||
pub pipeline: ModePipeline,
|
pub pipeline: ModePipeline,
|
||||||
pub optimize_setting: ModeOptimizerSetting,
|
pub optimize_setting: ModeOptimizerSetting,
|
||||||
@@ -62,6 +61,11 @@ impl Mode {
|
|||||||
None => default.into(),
|
None => default.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Should we go via Yul IR?
|
||||||
|
pub fn via_yul_ir(&self) -> bool {
|
||||||
|
self.pipeline == ModePipeline::Y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This represents a mode that has been parsed from test metadata.
|
/// This represents a mode that has been parsed from test metadata.
|
||||||
@@ -73,7 +77,8 @@ impl Mode {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// We can parse valid mode strings into [`ParsedMode`] using [`ParsedMode::from_str`].
|
/// We can parse valid mode strings into [`ParsedMode`] using [`ParsedMode::from_str`].
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
||||||
|
#[serde(try_from = "String", into = "String")]
|
||||||
pub struct ParsedMode {
|
pub struct ParsedMode {
|
||||||
pub pipeline: Option<ModePipeline>,
|
pub pipeline: Option<ModePipeline>,
|
||||||
pub optimize_flag: Option<bool>,
|
pub optimize_flag: Option<bool>,
|
||||||
@@ -129,26 +134,6 @@ impl FromStr for ParsedMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for ParsedMode {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let mode_string = String::deserialize(deserializer)?;
|
|
||||||
ParsedMode::from_str(&mode_string).map_err(serde::de::Error::custom)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for ParsedMode {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
let mode_string = self.to_string();
|
|
||||||
serializer.serialize_str(&mode_string)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ParsedMode {
|
impl Display for ParsedMode {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
fmt_mode_parts(
|
fmt_mode_parts(
|
||||||
@@ -161,6 +146,19 @@ impl Display for ParsedMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ParsedMode> for String {
|
||||||
|
fn from(parsed_mode: ParsedMode) -> Self {
|
||||||
|
parsed_mode.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<String> for ParsedMode {
|
||||||
|
type Error = ParseModeError;
|
||||||
|
fn try_from(value: String) -> Result<Self, Self::Error> {
|
||||||
|
ParsedMode::from_str(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn fmt_mode_parts(
|
fn fmt_mode_parts(
|
||||||
pipeline: Option<&ModePipeline>,
|
pipeline: Option<&ModePipeline>,
|
||||||
optimize_flag: Option<bool>,
|
optimize_flag: Option<bool>,
|
||||||
@@ -204,8 +202,8 @@ impl ParsedMode {
|
|||||||
|p| EitherIter::B(std::iter::once(*p)),
|
|p| EitherIter::B(std::iter::once(*p)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let optimize_flag_setting = self.optimize_flag.map(|b| {
|
let optimize_flag_setting = self.optimize_flag.map(|flag| {
|
||||||
if b {
|
if flag {
|
||||||
ModeOptimizerSetting::M3
|
ModeOptimizerSetting::M3
|
||||||
} else {
|
} else {
|
||||||
ModeOptimizerSetting::M0
|
ModeOptimizerSetting::M0
|
||||||
@@ -346,6 +344,11 @@ impl ModeOptimizerSetting {
|
|||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Are any optimizations enabled?
|
||||||
|
pub fn optimizations_enabled(&self) -> bool {
|
||||||
|
!matches!(self, ModeOptimizerSetting::M0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator that could be either of two iterators.
|
/// An iterator that could be either of two iterators.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use std::{
|
|||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use revive_dt_compiler::{CompilerInput, CompilerOutput};
|
use revive_dt_compiler::{CompilerInput, CompilerOutput};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
|
|
||||||
use revive_dt_config::{Arguments, TestingPlatform};
|
use revive_dt_config::{Arguments, TestingPlatform};
|
||||||
use revive_dt_format::{corpus::Corpus, mode::Mode};
|
use revive_dt_format::{corpus::Corpus, mode::Mode};
|
||||||
@@ -23,7 +23,7 @@ use crate::analyzer::CompilerStatistics;
|
|||||||
pub(crate) static REPORTER: OnceLock<Mutex<Report>> = OnceLock::new();
|
pub(crate) static REPORTER: OnceLock<Mutex<Report>> = OnceLock::new();
|
||||||
|
|
||||||
/// The `Report` datastructure stores all relevant inforamtion required for generating reports.
|
/// The `Report` datastructure stores all relevant inforamtion required for generating reports.
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize)]
|
||||||
pub struct Report {
|
pub struct Report {
|
||||||
/// The configuration used during the test.
|
/// The configuration used during the test.
|
||||||
pub config: Arguments,
|
pub config: Arguments,
|
||||||
@@ -41,7 +41,7 @@ pub struct Report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Contains a compiled contract.
|
/// Contains a compiled contract.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
pub struct CompilationTask {
|
pub struct CompilationTask {
|
||||||
/// The observed compiler input.
|
/// The observed compiler input.
|
||||||
pub json_input: CompilerInput,
|
pub json_input: CompilerInput,
|
||||||
@@ -56,7 +56,7 @@ pub struct CompilationTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a report about a compilation task.
|
/// Represents a report about a compilation task.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize)]
|
||||||
pub struct CompilationResult {
|
pub struct CompilationResult {
|
||||||
/// The observed compilation task.
|
/// The observed compilation task.
|
||||||
pub compilation_task: CompilationTask,
|
pub compilation_task: CompilationTask,
|
||||||
@@ -65,7 +65,7 @@ pub struct CompilationResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The [Span] struct indicates the context of what is being reported.
|
/// The [Span] struct indicates the context of what is being reported.
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize)]
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
/// The corpus index this belongs to.
|
/// The corpus index this belongs to.
|
||||||
corpus: usize,
|
corpus: usize,
|
||||||
|
|||||||
Reference in New Issue
Block a user