diff --git a/v2/robotmk/Cargo.lock b/v2/robotmk/Cargo.lock index b236fffe..c04fad91 100644 --- a/v2/robotmk/Cargo.lock +++ b/v2/robotmk/Cargo.lock @@ -862,16 +862,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "quick-xml" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "quote" version = "1.0.33" @@ -955,7 +945,6 @@ dependencies = [ "flexi_logger", "futures", "log", - "quick-xml", "serde", "serde_json", "sysinfo", diff --git a/v2/robotmk/Cargo.toml b/v2/robotmk/Cargo.toml index 76740107..596abce5 100644 --- a/v2/robotmk/Cargo.toml +++ b/v2/robotmk/Cargo.toml @@ -18,7 +18,6 @@ ctrlc = "*" flexi_logger = "*" futures = "*" log = "*" -quick-xml = { version = "0.30.0", features = ["serialize"] } serde = { version = "1.0.188", features = ["derive"] } serde_json = "*" sysinfo = "*" diff --git a/v2/robotmk/src/main.rs b/v2/robotmk/src/main.rs index 914795fb..866cf7c9 100644 --- a/v2/robotmk/src/main.rs +++ b/v2/robotmk/src/main.rs @@ -1,4 +1,3 @@ -#![allow(dead_code)] pub mod attempt; mod child_process_supervisor; mod cli; @@ -6,7 +5,6 @@ mod command_spec; mod config; mod environment; mod logging; -pub mod parse_xml; mod rebot; mod results; mod scheduling; diff --git a/v2/robotmk/src/parse_xml.rs b/v2/robotmk/src/parse_xml.rs deleted file mode 100644 index 84e2bb0f..00000000 --- a/v2/robotmk/src/parse_xml.rs +++ /dev/null @@ -1,90 +0,0 @@ -use chrono::NaiveDateTime; -use serde::de::Error; -use serde::{Deserialize, Deserializer}; - -#[derive(Deserialize)] -#[serde(rename_all = "UPPERCASE")] -enum Outcome { - Fail, - Pass, - Skip, - #[serde(rename = "NOT RUN")] - NotRun, -} - -fn parse_datetime<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - let raw = Deserialize::deserialize(deserializer)?; - NaiveDateTime::parse_from_str(raw, "%Y%m%d %H:%M:%S.%f") - .map_err(|_| Error::custom(format!("Invalid datetime: {}", raw))) -} - -#[derive(Deserialize)] -struct Rebot { - #[serde(rename = "@generator")] - generator: String, - #[serde(rename = "@generated", deserialize_with = "parse_datetime")] - generated: NaiveDateTime, - #[serde(rename = "@rpa")] - rpa: bool, - #[serde(rename = "@schemaversion")] - schemaversion: usize, - suite: Suite, - errors: Errors, -} - -#[derive(Deserialize)] -struct Suite { - #[serde(rename = "@id")] - id: String, - #[serde(rename = "@name")] - name: String, - #[serde(default)] - suite: Vec, - #[serde(default)] - test: Vec, -} - -#[derive(Deserialize)] -struct Status { - #[serde(rename = "@status")] - status: Outcome, - #[serde(rename = "@starttime", deserialize_with = "parse_datetime")] - starttime: NaiveDateTime, - #[serde(rename = "@endtime", deserialize_with = "parse_datetime")] - endtime: NaiveDateTime, -} - -#[derive(Deserialize)] -struct Test { - #[serde(rename = "@id")] - id: String, - #[serde(rename = "@name")] - name: String, - #[serde(rename = "@line")] - line: usize, - status: Status, -} - -#[derive(Deserialize)] -struct Errors {} - -#[cfg(test)] -mod tests { - use super::*; - use quick_xml::de::from_str; - use std::fs; - - #[test] - fn test_parse_rebot() { - let test_dir = format!("{}/tests/rebot.xml", env!("CARGO_MANIFEST_DIR")); - let xml = fs::read_to_string(&test_dir) - .unwrap_or_else(|_| panic!("Missing test data! {}", test_dir)); - let rebot: Rebot = from_str(&xml).unwrap(); - assert_eq!(rebot.generator, "Rebot 6.1.1 (Python 3.11.4 on win32)"); - assert!(!rebot.rpa); - assert_eq!(rebot.suite.suite.len(), 2); - } -}