mirror of
https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess.git
synced 2024-11-24 08:01:11 +09:00
update: Strict ordering for outpu (use BTreeMap instead of HashMap)
This commit is contained in:
parent
c4dd4161c7
commit
bdb415e6e6
3 changed files with 68 additions and 24 deletions
43
src/main.rs
43
src/main.rs
|
@ -1,6 +1,6 @@
|
||||||
use core::{panic, str};
|
use core::{panic, str};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::BTreeMap,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{BufRead, BufReader},
|
io::{BufRead, BufReader},
|
||||||
|
@ -31,7 +31,7 @@ struct Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Layer
|
/// Layer
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, PartialOrd, Ord)]
|
||||||
enum PositionLayer {
|
enum PositionLayer {
|
||||||
A,
|
A,
|
||||||
B,
|
B,
|
||||||
|
@ -61,7 +61,7 @@ impl FromStr for PositionLayer {
|
||||||
|
|
||||||
/// Where PS Board is placed while QAQC.
|
/// Where PS Board is placed while QAQC.
|
||||||
/// TODO: name
|
/// TODO: name
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, PartialOrd, Ord)]
|
||||||
struct Position {
|
struct Position {
|
||||||
major: PositionLayer,
|
major: PositionLayer,
|
||||||
minor: u8,
|
minor: u8,
|
||||||
|
@ -152,7 +152,7 @@ pub struct MasterLogResult {
|
||||||
version: Version,
|
version: Version,
|
||||||
datetime: DateTime<Utc>,
|
datetime: DateTime<Utc>,
|
||||||
shifter: String,
|
shifter: String,
|
||||||
board_results: HashMap<Position, MasterBoardResult>,
|
board_results: BTreeMap<Position, MasterBoardResult>,
|
||||||
filename: String,
|
filename: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ impl MasterLogResult {
|
||||||
return Err(anyhow!("Invalid log format"));
|
return Err(anyhow!("Invalid log format"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut assignments = HashMap::new();
|
let mut assignments = BTreeMap::new();
|
||||||
// till 19 for `===========`
|
// till 19 for `===========`
|
||||||
for i in 0..19 {
|
for i in 0..19 {
|
||||||
let line = lines.next().context("Unexpected EOF")??;
|
let line = lines.next().context("Unexpected EOF")??;
|
||||||
|
@ -265,7 +265,7 @@ impl MasterLogResult {
|
||||||
return Err(anyhow!("Invalid log format(result Station0)"));
|
return Err(anyhow!("Invalid log format(result Station0)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut board_results = HashMap::new();
|
let mut board_results = BTreeMap::new();
|
||||||
for station_minor in [0, 1] {
|
for station_minor in [0, 1] {
|
||||||
info!("Result for {:?}", station_minor);
|
info!("Result for {:?}", station_minor);
|
||||||
for _ in 1..10 {
|
for _ in 1..10 {
|
||||||
|
@ -507,6 +507,37 @@ mod test {
|
||||||
extract_position_id, extract_shifter_line, extract_version, Position, PositionLayer, PsbId,
|
extract_position_id, extract_shifter_line, extract_version, Position, PositionLayer, PsbId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn positionlayer_ordering() {
|
||||||
|
assert!(PositionLayer::A < PositionLayer::B)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn position_ordering() {
|
||||||
|
assert!(
|
||||||
|
Position {
|
||||||
|
major: PositionLayer::A,
|
||||||
|
minor: 1,
|
||||||
|
patch: 5
|
||||||
|
} < Position {
|
||||||
|
major: PositionLayer::A,
|
||||||
|
minor: 1,
|
||||||
|
patch: 7
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
Position {
|
||||||
|
major: PositionLayer::A,
|
||||||
|
minor: 1,
|
||||||
|
patch: 5
|
||||||
|
} < Position {
|
||||||
|
major: PositionLayer::A,
|
||||||
|
minor: 2,
|
||||||
|
patch: 3
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_position() {
|
fn parse_position() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
15
tests/cli.rs
15
tests/cli.rs
|
@ -1,5 +1,9 @@
|
||||||
mod integrated_test {
|
mod integrated_test {
|
||||||
use std::path::PathBuf;
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::{BufRead, BufReader},
|
||||||
|
path::PathBuf,
|
||||||
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use assert_cmd::{assert::OutputAssertExt, Command};
|
use assert_cmd::{assert::OutputAssertExt, Command};
|
||||||
|
@ -19,6 +23,15 @@ mod integrated_test {
|
||||||
.success()
|
.success()
|
||||||
.stdout(predicate::str::contains("Creating new file"));
|
.stdout(predicate::str::contains("Creating new file"));
|
||||||
|
|
||||||
|
// check output
|
||||||
|
{
|
||||||
|
let f = File::open(test_out.clone())?;
|
||||||
|
let r = BufReader::new(f);
|
||||||
|
assert!(r
|
||||||
|
.lines()
|
||||||
|
.any(|line| { line.unwrap().contains("8868,,A-0-1,0,1,1,0,1,8,1,") }));
|
||||||
|
}
|
||||||
|
|
||||||
// 2nd file
|
// 2nd file
|
||||||
let mut cmd = Command::cargo_bin("psb-qaqc-parse")?;
|
let mut cmd = Command::cargo_bin("psb-qaqc-parse")?;
|
||||||
cmd.current_dir("tests")
|
cmd.current_dir("tests")
|
||||||
|
|
|
@ -5,23 +5,23 @@ Shifters: alice
|
||||||
----------------------
|
----------------------
|
||||||
PBS Assignment:
|
PBS Assignment:
|
||||||
Position / assigned-ID : A-0-0 / PS008866
|
Position / assigned-ID : A-0-0 / PS008866
|
||||||
Position / assigned-ID : A-1-0 / PS008866
|
Position / assigned-ID : A-1-0 / PS008867
|
||||||
Position / assigned-ID : A-0-1 / PS008866
|
Position / assigned-ID : A-0-1 / PS008868
|
||||||
Position / assigned-ID : A-1-1 / PS008866
|
Position / assigned-ID : A-1-1 / PS008869
|
||||||
Position / assigned-ID : A-0-2 / PS008866
|
Position / assigned-ID : A-0-2 / PS008870
|
||||||
Position / assigned-ID : A-1-2 / PS008866
|
Position / assigned-ID : A-1-2 / PS008871
|
||||||
Position / assigned-ID : A-0-3 / PS008866
|
Position / assigned-ID : A-0-3 / PS008872
|
||||||
Position / assigned-ID : A-1-3 / PS008866
|
Position / assigned-ID : A-1-3 / PS008873
|
||||||
Position / assigned-ID : A-0-4 / PS008866
|
Position / assigned-ID : A-0-4 / PS008874
|
||||||
Position / assigned-ID : A-1-4 / PS008866
|
Position / assigned-ID : A-1-4 / PS008875
|
||||||
Position / assigned-ID : A-0-5 / PS008866
|
Position / assigned-ID : A-0-5 / PS008876
|
||||||
Position / assigned-ID : A-1-5 / PS008866
|
Position / assigned-ID : A-1-5 / PS008877
|
||||||
Position / assigned-ID : A-0-6 / PS008866
|
Position / assigned-ID : A-0-6 / PS008878
|
||||||
Position / assigned-ID : A-1-6 / PS008866
|
Position / assigned-ID : A-1-6 / PS008879
|
||||||
Position / assigned-ID : A-0-7 / PS008866
|
Position / assigned-ID : A-0-7 / PS008880
|
||||||
Position / assigned-ID : A-1-7 / PS008866
|
Position / assigned-ID : A-1-7 / PS008881
|
||||||
Position / assigned-ID : A-0-8 / PS008866
|
Position / assigned-ID : A-0-8 / PS008882
|
||||||
Position / assigned-ID : A-1-8 / PS008866
|
Position / assigned-ID : A-1-8 / PS008883
|
||||||
======================
|
======================
|
||||||
QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result |
|
QAQC status| QSPIp | Recov | Power | Clock | ASDTP | Reset | Result |
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue