Add an explainer mode to filecheck.
The -c flag to 'cton-util filecheck' will now print out a description of how the directives are matching the input. This explanation is also printed when a match fails.
This commit is contained in:
@@ -20,10 +20,21 @@ pub fn run(files: Vec<String>, verbose: bool) -> CommandResult {
|
||||
let mut buffer = String::new();
|
||||
try!(io::stdin().read_to_string(&mut buffer).map_err(|e| format!("stdin: {}", e)));
|
||||
|
||||
if try!(checker.check(&buffer, NO_VARIABLES).map_err(|e| e.to_string())) {
|
||||
if verbose {
|
||||
let (success, explain) = try!(checker.explain(&buffer, NO_VARIABLES)
|
||||
.map_err(|e| e.to_string()));
|
||||
print!("{}", explain);
|
||||
if success {
|
||||
println!("OK");
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Check failed".to_string())
|
||||
}
|
||||
} else if try!(checker.check(&buffer, NO_VARIABLES).map_err(|e| e.to_string())) {
|
||||
Ok(())
|
||||
} else {
|
||||
// TODO: We need to do better than this.
|
||||
let (_, explain) = try!(checker.explain(&buffer, NO_VARIABLES).map_err(|e| e.to_string()));
|
||||
print!("{}", explain);
|
||||
Err("Check failed".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user