cmake_parser/doc/command/ctest/
ctest_update.rs

1use cmake_parser_derive::CMake;
2
3use crate::{
4    doc::command_scope::{CommandScope, ToCommandScope},
5    Token,
6};
7
8/// Perform the CTest Update Step as a Dashboard Client.
9///
10/// Reference: <https://cmake.org/cmake/help/v3.26/command/ctest_update.html>
11#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate", allow_empty)]
13pub struct CTestUpdate<'t> {
14    #[cmake(rename = "SOURCE")]
15    pub source_dir: Option<Token<'t>>,
16    pub return_value: Option<Token<'t>>,
17    pub capture_cmake_error: Option<Token<'t>>,
18    pub quiet: bool,
19}
20
21impl<'t> ToCommandScope for CTestUpdate<'t> {
22    fn to_command_scope(&self) -> CommandScope {
23        CommandScope::CTest
24    }
25}
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30    use crate::doc::cmake_parse::tests::token;
31    use crate::*;
32    use pretty_assertions::assert_eq;
33
34    #[test]
35    fn ctest_update() {
36        let src = include_bytes!("../../../../../fixture/commands/ctest/ctest_update");
37        let cmakelists = parse_cmakelists(src).unwrap();
38        let doc = Doc::from(cmakelists);
39        assert_eq!(
40            doc.commands(),
41            Ok(vec![
42                Command::CTestUpdate(Box::new(CTestUpdate {
43                    source_dir: None,
44                    return_value: None,
45                    capture_cmake_error: None,
46                    quiet: false,
47                })),
48                Command::CTestUpdate(Box::new(CTestUpdate {
49                    source_dir: Some(token(b"source1")),
50                    return_value: Some(token(b"return_value1")),
51                    capture_cmake_error: Some(token(b"capture_cmake_error1")),
52                    quiet: true,
53                })),
54            ])
55        )
56    }
57}