cmake_parser/doc/command/project/
set_tests_properties.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    command::common::Property,
5    doc::command_scope::{CommandScope, ToCommandScope},
6    Token,
7};
8
9/// Set a property of the tests.
10///
11/// Reference: <https://cmake.org/cmake/help/v3.26/command/set_tests_properties.html>
12#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
13#[cmake(pkg = "crate", default = "tests")]
14pub struct SetTestsProperties<'t> {
15    #[cmake(rename = "")]
16    pub tests: Vec<Token<'t>>,
17    pub properties: Vec<Property<'t>>,
18}
19
20impl<'t> ToCommandScope for SetTestsProperties<'t> {
21    fn to_command_scope(&self) -> CommandScope {
22        CommandScope::Project
23    }
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29    use crate::doc::cmake_parse::tests::{token, tokens_vec};
30    use crate::*;
31    use pretty_assertions::assert_eq;
32
33    #[test]
34    fn set_tests_properties() {
35        let src = include_bytes!("../../../../../fixture/commands/project/set_tests_properties");
36        let cmakelists = parse_cmakelists(src).unwrap();
37        let doc = Doc::from(cmakelists);
38        assert_eq!(
39            doc.commands(),
40            Ok(vec![Command::SetTestsProperties(Box::new(
41                SetTestsProperties {
42                    tests: tokens_vec([b"test1", b"test2"]),
43                    properties: vec![
44                        Property {
45                            prop: token(b"prop1"),
46                            value: token(b"value1"),
47                        },
48                        Property {
49                            prop: token(b"prop2"),
50                            value: token(b"value2"),
51                        }
52                    ]
53                }
54            )),])
55        )
56    }
57}