Add test with standard json args

This commit is contained in:
Sebastian Miasojed
2024-11-18 16:52:56 +01:00
parent 63da7212a1
commit 39e504703e
3 changed files with 75 additions and 17 deletions
@@ -12,6 +12,8 @@ use std::path::PathBuf;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use serde::Deserialize;
use serde::Serialize;
#[cfg(target_os = "emscripten")]
use std::fs::File;
use crate::solc::pipeline::Pipeline as SolcPipeline;
use crate::solc::standard_json::input::settings::metadata::Metadata as SolcStandardJsonInputSettingsMetadata;
@@ -41,7 +43,20 @@ pub struct Input {
impl Input {
/// A shortcut constructor from stdin.
pub fn try_from_stdin(solc_pipeline: SolcPipeline) -> anyhow::Result<Self> {
let mut input: Self = serde_json::from_reader(std::io::BufReader::new(std::io::stdin()))?;
let mut input: Self = serde_json::from_reader({
#[cfg(target_os = "emscripten")]
{
std::io::BufReader::new(
File::open("/in")
.map_err(|error| anyhow::anyhow!("File /in openning error: {}", error))?,
)
}
#[cfg(not(target_os = "emscripten"))]
{
std::io::BufReader::new(std::io::stdin())
}
})?;
input
.settings
.output_selection