Skip to content
Snippets Groups Projects
Verified Commit 0cd4e349 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Formatting of tests runner

parent 7fd366be
No related branches found
No related tags found
1 merge request!333Convert test runner to rust
Pipeline #9144 passed with warnings
use std::{ use std::{
env, env, fs,
fs,
io::{self, Write}, io::{self, Write},
path::PathBuf, path::PathBuf,
process::{self, Command, ExitStatus}, process::{self, Command, ExitStatus},
}; };
fn expected(bin: &str, kind: &str, generated: &[u8], status: ExitStatus) -> Result<(), String> { fn expected(bin: &str, kind: &str, generated: &[u8], status: ExitStatus) -> Result<(), String> {
let mut expected_file = PathBuf::from(format!( let mut expected_file = PathBuf::from(format!("expected/{}.{}", bin, kind));
"expected/{}.{}", if !expected_file.exists() {
bin,
kind
));
if ! expected_file.exists() {
expected_file = PathBuf::from(format!( expected_file = PathBuf::from(format!(
"expected/{}.{}", "expected/{}.{}",
bin.replace("bins_static", "").replace("bins_dynamic", ""), bin.replace("bins_static", "").replace("bins_dynamic", ""),
...@@ -41,9 +36,7 @@ fn expected(bin: &str, kind: &str, generated: &[u8], status: ExitStatus) -> Resu ...@@ -41,9 +36,7 @@ fn expected(bin: &str, kind: &str, generated: &[u8], status: ExitStatus) -> Resu
return Err(format!( return Err(format!(
"{} failed - retcode {}, {} mismatch", "{} failed - retcode {}, {} mismatch",
bin, bin, status, kind
status,
kind
)); ));
} }
...@@ -67,7 +60,7 @@ fn main() { ...@@ -67,7 +60,7 @@ fn main() {
println!("{}", failure); println!("{}", failure);
failures.push(failure); failures.push(failure);
} }
}, }
Err(err) => { Err(err) => {
let failure = format!("{}: failed to execute: {}", bin, err); let failure = format!("{}: failed to execute: {}", bin, err);
println!("{}", failure); println!("{}", failure);
...@@ -76,7 +69,7 @@ fn main() { ...@@ -76,7 +69,7 @@ fn main() {
} }
} }
if ! failures.is_empty() { if !failures.is_empty() {
println!("# FAILURES #"); println!("# FAILURES #");
for failure in failures { for failure in failures {
println!("{}", failure); println!("{}", failure);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment