mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-05-01 11:07:58 +00:00
Implement basic reporting facility (#18)
* wip Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * save to file after all tasks done Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * error out early if the workdir does not exist Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * the compiler statistics Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * allow compiler statistics per implementation Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * save compiler problems Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * add flag whether to extract compiler errors Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> * whitespace Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -48,8 +48,12 @@ pub struct CompilerInput<T: PartialEq + Eq + Hash> {
|
||||
|
||||
/// The generic compilation output configuration.
|
||||
pub struct CompilerOutput<T: PartialEq + Eq + Hash> {
|
||||
/// The solc standard JSON input.
|
||||
pub input: CompilerInput<T>,
|
||||
/// The produced solc standard JSON output.
|
||||
pub output: SolcStandardJsonOutput,
|
||||
/// The error message in case the compiler returns abnormally.
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl<T> PartialEq for CompilerInput<T>
|
||||
@@ -110,6 +114,7 @@ where
|
||||
false,
|
||||
),
|
||||
None,
|
||||
None,
|
||||
),
|
||||
},
|
||||
extra_options: Default::default(),
|
||||
@@ -156,4 +161,9 @@ where
|
||||
input: self.input,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the compiler JSON input.
|
||||
pub fn input(&self) -> SolcStandardJsonInput {
|
||||
self.input.clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,18 @@ impl SolidityCompiler for Resolc {
|
||||
let stderr = output.stderr;
|
||||
|
||||
if !output.status.success() {
|
||||
let message = String::from_utf8_lossy(&stderr);
|
||||
log::error!(
|
||||
"resolc failed exit={} stderr={} JSON-in={} ",
|
||||
output.status,
|
||||
String::from_utf8_lossy(&stderr),
|
||||
&message,
|
||||
json_in,
|
||||
);
|
||||
return Ok(CompilerOutput {
|
||||
input,
|
||||
output: Default::default(),
|
||||
error: Some(message.into()),
|
||||
});
|
||||
}
|
||||
|
||||
let parsed: SolcStandardJsonOutput = serde_json::from_slice(&stdout).map_err(|e| {
|
||||
@@ -59,6 +65,7 @@ impl SolidityCompiler for Resolc {
|
||||
Ok(CompilerOutput {
|
||||
input,
|
||||
output: parsed,
|
||||
error: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,22 @@ impl SolidityCompiler for Solc {
|
||||
|
||||
let stdin = child.stdin.as_mut().expect("should be piped");
|
||||
serde_json::to_writer(stdin, &input.input)?;
|
||||
let output = child.wait_with_output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
let message = String::from_utf8_lossy(&output.stderr);
|
||||
log::error!("solc failed exit={} stderr={}", output.status, &message);
|
||||
return Ok(CompilerOutput {
|
||||
input,
|
||||
output: Default::default(),
|
||||
error: Some(message.into()),
|
||||
});
|
||||
}
|
||||
|
||||
let output = child.wait_with_output()?.stdout;
|
||||
Ok(CompilerOutput {
|
||||
input,
|
||||
output: serde_json::from_slice(&output)?,
|
||||
output: serde_json::from_slice(&output.stdout)?,
|
||||
error: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user