cmake_parser/doc/command/ctest/
ctest_configure.rs

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