cmake_file_api/objects/
configure_log_v1.rs

1use crate::objects::{MajorMinor, Object, ObjectKind};
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5/// The configureLog object kind describes the location and contents of a cmake-configure-log(7) file.
6#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8#[non_exhaustive]
9pub struct ConfigureLog {
10    /// Kind of the configureLog object.
11    pub kind: ObjectKind,
12
13    /// Version of the configureLog object.
14    pub version: MajorMinor,
15
16    /// Path to the configure log file.
17    /// Clients must read the log file from this path, which may be different from the path documented by cmake-configure-log(7).
18    /// The log file may not exist if no events are logged.
19    pub path: PathBuf,
20
21    /// Names of the event kinds that are logged in the configure log.
22    pub event_kind_names: Vec<String>,
23}
24
25impl Object for ConfigureLog {
26    fn kind() -> ObjectKind {
27        ObjectKind::ConfigureLog
28    }
29
30    fn major() -> u32 {
31        1
32    }
33}
34
35#[cfg(test)]
36mod tests {
37    use crate::objects::configure_log_v1::*;
38    use crate::objects::MajorMinor;
39    use serde_json::json;
40
41    #[test]
42    fn test_configure_log() {
43        let json = json!({
44          "kind" : "configureLog",
45          "path" : "build/CMakeFiles/CMakeConfigureLog.yaml",
46          "version" :
47          {
48            "major" : 1,
49            "minor" : 0
50          },
51          "eventKindNames" :
52          [
53            "message-v1",
54            "try_compile-v1",
55            "try_run-v1"
56          ]
57        });
58
59        let configure_log = serde_json::from_value::<ConfigureLog>(json).unwrap();
60        assert_eq!(
61            configure_log,
62            ConfigureLog {
63                event_kind_names: vec![
64                    "message-v1".into(),
65                    "try_compile-v1".into(),
66                    "try_run-v1".into()
67                ],
68                kind: ObjectKind::ConfigureLog,
69                path: "build/CMakeFiles/CMakeConfigureLog.yaml".into(),
70                version: MajorMinor { major: 1, minor: 0 }
71            }
72        );
73    }
74}