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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#######################################################
#
# Test command modules
# Redmine#3991: support data containers
#
#######################################################
body common control
{
inputs => { "../../default.cf.sub", "../../plucked.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
version => "1.0";
}
#######################################################
bundle agent init
{
vars:
"script_name" string => "$(this.promise_filename).txt";
}
#######################################################
bundle agent test
{
commands:
"$(G.cat) $(init.script_name)"
contain => in_shell,
module => "true";
}
#######################################################
bundle agent check
{
vars:
"list0" slist => {"abc", "def", "ghi"};
"list1" slist => {"{{abc}}", " ' def}", "ghi'''"};
"list2" slist => {'{{a,bc}}', ' " de,f}', 'gh,,i"""'};
"list3" slist => {"{{a'bc',,}}", ' ",, d"ef}', "ghi,},'''"};
"actual0" string => join(":", "list0");
"actual1" string => join(":", "list1");
"actual2" string => join(":", "list2");
"actual3" string => join(":", "list3");
"joined0" string => join(":", "xyz_123___456.mylist");
"joined1" string => join(":", "xyz_123___456.myalist");
"joined2" string => join(":", "xyz_123___456.myblist");
"joined3" string => join(":", "xyz_123___456.myclist");
"c" slist => { "1", "2", "3", "4", "5", "6" };
"c$(c)" string => format("%S", "xyz_123___456.mycontainer$(c)");
"e1" string => '{"x":[456,789]}';
"e5" string => '["read","some","strings"]';
"e6" string => '{"mix":["match"],"nothing":null,"paddle":true,"ping":"pong"}';
"hello_contexts" slist => { "xyz_123___456", "_456", "456", "_", "a__456__", "__a__", };
classes:
any::
"var0ok" expression => strcmp("${this.joined0}" , "${this.actual0}");
"var1ok" expression => strcmp("${this.joined1}" , "${this.actual1}");
"var2ok" expression => strcmp("${this.joined2}" , "${this.actual2}");
"var3ok" expression => strcmp("${this.joined3}" , "${this.actual3}");
"var4ok" expression => strcmp("hello there" , "${xyz_123___456.myvar}");
"hello_$(hello_contexts)_ok" expression => strcmp("hello there" , "${$(hello_contexts).myvar}");
"ok_c1" expression => strcmp($(e1) , $(c1));
"ok_c2" not => isvariable("c2");
"ok_c3" not => isvariable("c3");
"ok_c4" not => isvariable("c4");
"ok_c5" expression => strcmp($(e5) , $(c5));
"ok_c6" expression => strcmp($(e6) , $(c6));
"ok_injected_var" -> { "CFE-1915" }
expression => strcmp($(test.myvar), "hello there"),
comment => "This remote variable injection should work, BUT IS A DIRTY HACK!";
"ok" and => { "myclass", "var0ok", "var1ok", "var2ok", "var3ok", "var4ok",
"hello_xyz_123___456_ok", "hello__456_ok", "hello_456_ok", "hello___ok", "hello_a__456___ok", "hello___a___ok",
"ok_c1", "ok_c2", "ok_c3", "ok_c4", "ok_c5", "ok_c6",
"ok_injected_var" };
reports:
DEBUG::
"container $(c): $(e$(c)) != $(c$(c))"
ifvarclass => "!ok_c$(c)";
"context $(hello_contexts) failed" ifvarclass => "!hello_$(hello_contexts)_ok";
"test.myvar = $(test.myvar)"
ifvarclass => "!ok_injected_var";
EXTRA::
"context $(hello_contexts) worked" ifvarclass => "hello_$(hello_contexts)_ok";
ok::
"$(this.promise_filename) Pass";
!ok::
"$(this.promise_filename) FAIL";
}
### PROJECT_ID: core
### CATEGORY_ID: 26
|