cmake_parser/doc/command/project/
add_test.rs1use ::cmake_parser_derive::CMake;
2
3use crate::{command::common::CustomCommand, CommandScope, ToCommandScope, Token};
4
5#[derive(CMake, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[cmake(pkg = "crate")]
10pub struct AddTest<'t> {
11 name: Token<'t>,
12 #[cmake(rename = "COMMAND")]
13 commands: Vec<CustomCommand<'t>>,
14 configurations: Option<Vec<Vec<Token<'t>>>>,
15 working_directory: Option<Token<'t>>,
16 command_expand_lists: bool,
17}
18
19impl<'t> ToCommandScope for AddTest<'t> {
20 fn to_command_scope(&self) -> CommandScope {
21 CommandScope::Project
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28 use crate::doc::cmake_parse::tests::tokens;
29 use crate::*;
30
31 #[test]
32 fn add_test() {
33 let src = include_bytes!("../../../../../fixture/commands/project/add_test");
34 let cmakelists = parse_cmakelists(src).unwrap();
35 let doc = Doc::from(cmakelists);
36
37 assert_eq!(
38 doc.commands(),
39 Ok(vec![
40 Command::AddTest(Box::new(AddTest {
41 name: b"runtest".into(),
42 commands: vec![CustomCommand {
43 name: b"runtest".into(),
44 args: Some(tokens([b"--out", b"${CMAKE_CURRENT_BINARY_DIR}"]).to_vec()),
45 }],
46 configurations: None,
47 working_directory: Some(b"${CMAKE_CURRENT_SOURCE_DIR}".into()),
48 command_expand_lists: false,
49 })),
50 Command::AddTest(Box::new(AddTest {
51 name: b"TestInstantiator".into(),
52 commands: vec![CustomCommand {
53 name: b"TestInstantiator".into(),
54 args: None,
55 }],
56 configurations: None,
57 working_directory: None,
58 command_expand_lists: true,
59 })),
60 ])
61 )
62 }
63}