Use 1-indexed rows in CLI and log output (resolves #287)
This commit is contained in:
parent
1aaad66a03
commit
c8d040ca26
6 changed files with 33 additions and 10 deletions
|
|
@ -56,6 +56,10 @@ fn test_parsing_with_logging() {
|
|||
"reduce sym:struct_item, child_count:3".to_string()
|
||||
)));
|
||||
assert!(messages.contains(&(LogType::Lex, "skip character:' '".to_string())));
|
||||
|
||||
for (_, m) in &messages {
|
||||
assert!(!m.contains("row:0"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ impl Drop for LogSession {
|
|||
{
|
||||
Command::new("open").arg(&self.0).output().unwrap();
|
||||
}
|
||||
|
||||
#[cfg(any(debug_assertions, test))]
|
||||
validate_graph_log(&self);
|
||||
} else {
|
||||
eprintln!(
|
||||
"Dot failed: {} {}",
|
||||
|
|
@ -64,3 +67,19 @@ impl Drop for LogSession {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(unix, any(debug_assertions, test)))]
|
||||
fn validate_graph_log(session: &LogSession) {
|
||||
use std::io::{BufRead, BufReader};
|
||||
|
||||
let has_zero_indexed_row = |s: &str| s.contains("position: 0,");
|
||||
|
||||
let graph_log = std::fs::File::open(&session.0)
|
||||
.expect("Failed to open graph log");
|
||||
let log_reader = BufReader::new(graph_log)
|
||||
.lines()
|
||||
.map(|l| l.expect("Failed to read line from graph log"));
|
||||
for line in log_reader {
|
||||
assert!(!has_zero_indexed_row(&line), "Graph log output includes zero-indexed row: {}", line);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue