mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-04-30 09:28:00 +00:00
Request VersionOrRequirement in compiler interface
This commit is contained in:
@@ -13,6 +13,7 @@ use alloy_primitives::Address;
|
||||
use revive_dt_config::Arguments;
|
||||
|
||||
use revive_common::EVMVersion;
|
||||
use revive_dt_solc_binaries::download::VersionOrRequirement;
|
||||
use revive_solc_json_interface::{
|
||||
SolcStandardJsonInput, SolcStandardJsonInputLanguage, SolcStandardJsonInputSettings,
|
||||
SolcStandardJsonInputSettingsOptimizer, SolcStandardJsonInputSettingsSelection,
|
||||
@@ -37,7 +38,10 @@ pub trait SolidityCompiler {
|
||||
|
||||
fn new(solc_executable: PathBuf) -> Self;
|
||||
|
||||
fn get_compiler_executable(config: &Arguments, version: Version) -> anyhow::Result<PathBuf>;
|
||||
fn get_compiler_executable(
|
||||
config: &Arguments,
|
||||
version: impl Into<VersionOrRequirement>,
|
||||
) -> anyhow::Result<PathBuf>;
|
||||
}
|
||||
|
||||
/// The generic compilation input configuration.
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::{
|
||||
|
||||
use crate::{CompilerInput, CompilerOutput, SolidityCompiler};
|
||||
use revive_dt_config::Arguments;
|
||||
use revive_dt_solc_binaries::download::VersionOrRequirement;
|
||||
use revive_solc_json_interface::SolcStandardJsonOutput;
|
||||
|
||||
// TODO: I believe that we need to also pass the solc compiler to resolc so that resolc uses the
|
||||
@@ -147,7 +148,7 @@ impl SolidityCompiler for Resolc {
|
||||
|
||||
fn get_compiler_executable(
|
||||
config: &Arguments,
|
||||
_version: semver::Version,
|
||||
_version: impl Into<VersionOrRequirement>,
|
||||
) -> anyhow::Result<PathBuf> {
|
||||
if !config.resolc.as_os_str().is_empty() {
|
||||
return Ok(config.resolc.clone());
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
|
||||
use crate::{CompilerInput, CompilerOutput, SolidityCompiler};
|
||||
use revive_dt_config::Arguments;
|
||||
use revive_dt_solc_binaries::download_solc;
|
||||
use revive_dt_solc_binaries::{download::VersionOrRequirement, download_solc};
|
||||
use revive_solc_json_interface::SolcStandardJsonOutput;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -95,7 +95,7 @@ impl SolidityCompiler for Solc {
|
||||
|
||||
fn get_compiler_executable(
|
||||
config: &Arguments,
|
||||
version: semver::Version,
|
||||
version: impl Into<VersionOrRequirement>,
|
||||
) -> anyhow::Result<PathBuf> {
|
||||
let path = download_solc(config.directory(), version, config.wasm)?;
|
||||
Ok(path)
|
||||
|
||||
@@ -145,6 +145,28 @@ impl From<VersionReq> for VersionOrRequirement {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<VersionOrRequirement> for Version {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: VersionOrRequirement) -> Result<Self, Self::Error> {
|
||||
let VersionOrRequirement::Version(version) = value else {
|
||||
anyhow::bail!("Version or requirement was not a version");
|
||||
};
|
||||
Ok(version)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<VersionOrRequirement> for VersionReq {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: VersionOrRequirement) -> Result<Self, Self::Error> {
|
||||
let VersionOrRequirement::Requirement(requirement) = value else {
|
||||
anyhow::bail!("Version or requirement was not a requirement");
|
||||
};
|
||||
Ok(requirement)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{download::GHDownloader, list::List};
|
||||
|
||||
Reference in New Issue
Block a user