mirror of
https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess.git
synced 2025-07-02 01:29:28 +09:00
fix: master log parse (invalid station detection in status parse)
- missed switch for `Station1` - added integrated test to check lines count of output csv
This commit is contained in:
parent
e20c029684
commit
fb5160d2d9
2 changed files with 30 additions and 21 deletions
|
@ -2,7 +2,7 @@ use std::{collections::BTreeMap, io::BufRead, str::FromStr};
|
|||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use chrono::{DateTime, Utc};
|
||||
use log::{debug, info, trace};
|
||||
use log::{debug, error, info, trace};
|
||||
use regex::Regex;
|
||||
use semver::Version;
|
||||
|
||||
|
@ -123,7 +123,9 @@ impl MasterLogResult {
|
|||
debug!("End of assignments");
|
||||
break;
|
||||
}
|
||||
debug!("line: {}", line);
|
||||
let (pos, id) = extract_position_id(&line)?;
|
||||
trace!("pos: {}", pos);
|
||||
match assignments.insert(pos.clone(), id) {
|
||||
None => (),
|
||||
Some(old_id) => {
|
||||
|
@ -163,9 +165,17 @@ impl MasterLogResult {
|
|||
let mut board_results = BTreeMap::new();
|
||||
for station_minor in [0, 1] {
|
||||
info!("Result for {:?}", station_minor);
|
||||
for _ in 1..10 {
|
||||
|
||||
// Loop for sufficiently large number to reach `Station1`
|
||||
for _ in 1..20 {
|
||||
let line = lines.next().context("Invalid log format(result body)")??;
|
||||
if line.contains("Station1") || line.contains("======") {
|
||||
trace!("line: {}", line);
|
||||
if line.contains("======") {
|
||||
// end of status
|
||||
break;
|
||||
}
|
||||
if line.contains(&format!("Station{}", station_minor + 1)) {
|
||||
debug!("Next station: line: {}", line);
|
||||
break;
|
||||
}
|
||||
let parts: Vec<&str> = line.split('|').collect();
|
||||
|
@ -182,7 +192,7 @@ impl MasterLogResult {
|
|||
.parse::<u8>()
|
||||
})
|
||||
}
|
||||
.context("Invalid station format")??;
|
||||
.context(format!("Invalid station format: {}", line))??;
|
||||
let station_id = match station_minor {
|
||||
0 => raw_station_id,
|
||||
1 => raw_station_id - 10,
|
||||
|
@ -283,14 +293,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn parse_runid_line() {
|
||||
assert_eq!(
|
||||
extract_runid_line("QAQC runid: 7").unwrap(),
|
||||
7
|
||||
);
|
||||
assert_eq!(
|
||||
extract_runid_line("QAQC runid: 12345").unwrap(),
|
||||
12345
|
||||
);
|
||||
assert_eq!(extract_runid_line("QAQC runid: 7").unwrap(), 7);
|
||||
assert_eq!(extract_runid_line("QAQC runid: 12345").unwrap(), 12345);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue