cmake_parser/doc/command/ctest/
ctest_run_script.rs1use cmake_parser_derive::CMake;
2
3use crate::{
4 doc::command_scope::{CommandScope, ToCommandScope},
5 Token,
6};
7
8#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cmake(pkg = "crate", allow_empty, default = "scripts")]
13pub struct CTestRunScript<'t> {
14 pub new_process: bool,
15 #[cmake(rename = "")]
16 pub scripts: Option<Vec<Token<'t>>>,
17 pub return_value: Option<Token<'t>>,
18}
19
20impl<'t> ToCommandScope for CTestRunScript<'t> {
21 fn to_command_scope(&self) -> CommandScope {
22 CommandScope::CTest
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 ctest_run_script() {
35 let src = include_bytes!("../../../../../fixture/commands/ctest/ctest_run_script");
36 let cmakelists = parse_cmakelists(src).unwrap();
37 let doc = Doc::from(cmakelists);
38 assert_eq!(
39 doc.commands(),
40 Ok(vec![
41 Command::CTestRunScript(Box::new(CTestRunScript {
42 new_process: false,
43 scripts: None,
44 return_value: None,
45 })),
46 Command::CTestRunScript(Box::new(CTestRunScript {
47 new_process: true,
48 scripts: Some(tokens_vec([b"script1", b"script2", b"script3"])),
49 return_value: Some(token(b"return_value1")),
50 })),
51 ])
52 )
53 }
54}