File: module_allows_trailing_comma.cf

package info (click to toggle)
cfengine3 3.15.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 34,456 kB
  • sloc: ansic: 145,932; sh: 8,550; makefile: 1,558; yacc: 1,192; python: 1,056; lex: 758; perl: 211; pascal: 149; awk: 58; xml: 21; sed: 13
file content (67 lines) | stat: -rw-r--r-- 1,774 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#######################################################
#
# Test that modules are allowed to define lists with trailing commas
#
#######################################################

body common control
{
      inputs => { "../../default.cf.sub" };
      bundlesequence  => { default("$(this.promise_filename)") };
      version => "1.0";
}

#######################################################

bundle agent test
{
  meta:
      "test_soft_fail" string => "any",
        meta => { "redmine7578" };

  commands:
      "$(G.cat)"
        args => "$(this.promise_filename).txt",
        module => "true";
}

#######################################################

bundle agent check
{
  vars:
    "length_of_list_from_module"
      int => length("default:cat.list_from_module");

  classes:
    "have_list_from_module"
      expression => isvariable("default:cat.list_from_module"),
      comment => "Modules should be able to define empty/null lists.";

    "list_from_module_length_1"
      expression => strcmp(1, $(length_of_list_from_module));

    "ok"
      and => { "have_list_from_module", "list_from_module_length_1" },
      comment => "OK since we can both define a list with a trailing comma, and
                  its length is 1 as expected";

  reports:
    DEBUG|DEBUG_check::
    "DEBUG $(this.bundle): Module defined 'default:cat.list_from_module'"
      if => "have_list_from_module";

    "DEBUG $(this.bundle): The list defined from the module had the expected length of 0"
      if => "list_from_module_length_1";

    "DEBUG $(this.bundle): length of list from module '$(length_of_list_from_module)'";

    ok::
      "$(this.promise_filename) Pass";
    !ok::
      "$(this.promise_filename) FAIL";

}

### PROJECT_ID: core
### CATEGORY_ID: 26