mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-07-12 23:45:45 +00:00
Use the solc version required in tests rather than one on PATH
This commit is contained in:
@@ -7,6 +7,7 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use cache::get_or_download;
|
||||
use download::SolcDownloader;
|
||||
use semver::Version;
|
||||
|
||||
use revive_dt_common::types::VersionOrRequirement;
|
||||
|
||||
@@ -14,6 +15,25 @@ pub mod cache;
|
||||
pub mod download;
|
||||
pub mod list;
|
||||
|
||||
/// Return a [`SolcDownloader`] which can be used to download a `solc`
|
||||
/// binary or return the resolved version it will download.
|
||||
async fn downloader(
|
||||
version: impl Into<VersionOrRequirement>,
|
||||
wasm: bool,
|
||||
) -> anyhow::Result<SolcDownloader> {
|
||||
if wasm {
|
||||
SolcDownloader::wasm(version).await
|
||||
} else if cfg!(target_os = "linux") {
|
||||
SolcDownloader::linux(version).await
|
||||
} else if cfg!(target_os = "macos") {
|
||||
SolcDownloader::macosx(version).await
|
||||
} else if cfg!(target_os = "windows") {
|
||||
SolcDownloader::windows(version).await
|
||||
} else {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
/// Downloads the solc binary for Wasm is `wasm` is set, otherwise for
|
||||
/// the target platform.
|
||||
///
|
||||
@@ -24,17 +44,16 @@ pub async fn download_solc(
|
||||
version: impl Into<VersionOrRequirement>,
|
||||
wasm: bool,
|
||||
) -> anyhow::Result<PathBuf> {
|
||||
let downloader = if wasm {
|
||||
SolcDownloader::wasm(version).await
|
||||
} else if cfg!(target_os = "linux") {
|
||||
SolcDownloader::linux(version).await
|
||||
} else if cfg!(target_os = "macos") {
|
||||
SolcDownloader::macosx(version).await
|
||||
} else if cfg!(target_os = "windows") {
|
||||
SolcDownloader::windows(version).await
|
||||
} else {
|
||||
unimplemented!()
|
||||
}?;
|
||||
|
||||
let downloader = downloader(version, wasm).await?;
|
||||
get_or_download(cache_directory, &downloader).await
|
||||
}
|
||||
|
||||
/// Return the version of solc that will be downloaded via [`download_solc`]
|
||||
/// given the version requirements and wasm flag.
|
||||
pub async fn solc_version(
|
||||
version: impl Into<VersionOrRequirement>,
|
||||
wasm: bool,
|
||||
) -> anyhow::Result<Version> {
|
||||
let downloader = downloader(version, wasm).await?;
|
||||
Ok(downloader.version.clone())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user