mirror of
https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess.git
synced 2024-11-21 23:00:20 +09:00
add: check-db command & add-skew command protoptype
This commit is contained in:
parent
e856f1575a
commit
fb11f18bbb
3 changed files with 39 additions and 11 deletions
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
|
||||
- Subcommand `add-master-log` to parse master log for shiftwork 0.1.0 and write out to CSV
|
||||
- Subcommand `add-master-log` to parse master log for shiftwork 0.1.0 and write out to CSV.
|
||||
- Subcommand `check-db` to validate the database CSV file.
|
||||
|
||||
[Unreleased]: https://gitlab.cern.ch
|
||||
|
|
37
src/main.rs
37
src/main.rs
|
@ -37,6 +37,18 @@ pub enum Commands {
|
|||
// #[arg(default_value = get_default_log_path().into_os_string())]
|
||||
outfile: PathBuf,
|
||||
},
|
||||
/// Check CSV format
|
||||
CheckDB {
|
||||
/// Database CSV file.
|
||||
csvfile: PathBuf,
|
||||
},
|
||||
/// Get LVDS TX skew from slave log _clk file.
|
||||
AddSkew {
|
||||
/// Slave _clk log file.
|
||||
logfile: PathBuf,
|
||||
/// Output CSV file.
|
||||
outfile: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
/// Layer
|
||||
|
@ -473,15 +485,6 @@ fn main() -> Result<()> {
|
|||
};
|
||||
debug!("{:?}", result);
|
||||
|
||||
// {
|
||||
// let file = File::options()
|
||||
// .read(true)
|
||||
// .open(args.outfile)?;
|
||||
//
|
||||
// let mut rdr = csv::Reader::from_reader(file);
|
||||
// rdr.records();
|
||||
// }
|
||||
|
||||
let expanded_results = PsbQaqcResult::from_masterlogresult(result);
|
||||
|
||||
let mut wtr = match outfile.exists() {
|
||||
|
@ -504,6 +507,22 @@ fn main() -> Result<()> {
|
|||
}
|
||||
wtr.flush()?;
|
||||
}
|
||||
Commands::CheckDB { csvfile } => {
|
||||
// TODO: more friendly message (like row number)
|
||||
// TODO: more validation options (e.g. for each stage(Master log, Slave log(end of
|
||||
// campaign)))
|
||||
// TODO: Masterログが得られたときや、行として完成していかないときなど複数段階のチェックを用意する
|
||||
let file = File::options().read(true).open(csvfile)?;
|
||||
|
||||
let rdr = csv::Reader::from_reader(file);
|
||||
if !rdr
|
||||
.into_deserialize::<PsbQaqcResult>()
|
||||
.all(|row| row.is_ok())
|
||||
{
|
||||
return Err(anyhow!("Invalid csv"));
|
||||
};
|
||||
}
|
||||
Commands::AddSkew { logfile, outfile } => todo!("Not implemented"),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
10
tests/cli.rs
10
tests/cli.rs
|
@ -6,7 +6,7 @@ mod integrated_test {
|
|||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use assert_cmd::{assert::OutputAssertExt, Command};
|
||||
use assert_cmd::Command;
|
||||
use predicates::prelude::*;
|
||||
|
||||
#[test]
|
||||
|
@ -42,6 +42,14 @@ mod integrated_test {
|
|||
.assert()
|
||||
.success();
|
||||
|
||||
// check
|
||||
let mut cmd = Command::cargo_bin("psb-qaqc")?;
|
||||
cmd.current_dir("tests")
|
||||
.arg("check-db")
|
||||
.arg(test_out.as_path())
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue