1####################################################### 2# 3# Test findfiles() 4# 5####################################################### 6 7body common control 8{ 9 inputs => { "../../default.cf.sub" }; 10 bundlesequence => { default("$(this.promise_filename)") }; 11 version => "1.0"; 12} 13 14bundle common findfiles 15{ 16 vars: 17 # * in filenames not allowed on win 18 windows:: 19 "names" slist => { "a", "bc", "d/e/f", "g/h/i/j", "klm/nop/qrs" }; 20 !windows:: 21 "names" slist => { "a", "bc", "d/e/f", "g/h/i/j", "klm/nop/qrs", "tu/*" }; 22} 23 24####################################################### 25 26bundle agent init 27{ 28 files: 29 "$(G.testdir)/$(findfiles.names)" 30 create => "true"; 31 32 reports: 33 DEBUG:: 34 "Created $(G.testdir)/$(findfiles.names)"; 35} 36 37 38####################################################### 39 40bundle agent test 41{ 42 meta: 43 "test_suppress_fail" string => "windows", 44 meta => { "redmine4730" }; 45 46 vars: 47 "patterns[a]" string => "$(G.testdir)/?"; 48 "patterns[b]" string => "$(G.testdir)/*"; 49 "patterns[c]" string => "$(G.testdir)/?/*"; 50 "patterns[d]" string => "$(G.testdir)/[ab]*"; 51 "patterns[e]" string => "$(G.testdir)/nosuch/*"; 52 "patterns[relative_path_1]" string => "./*"; 53 "patterns[relative_path_2]" string => "**"; 54 "patterns[relative_path_3]" string => "../**"; 55 56 !windows:: 57 "patterns[f]" string => "$(G.testdir)/tu/\\*"; 58 "patterns[g]" string => "$(G.testdir)/**"; 59 "patterns[h]" string => "$(G.testdir)/**/j"; 60 61 any:: 62 "pnames" slist => getindices("patterns"); 63 64 "found[$(pnames)]" slist => findfiles("$(patterns[$(pnames)])"); 65 "found_string[$(pnames)]" string => join(",", "found[$(pnames)]"); 66 67 68 reports: 69 DEBUG:: 70 "findfiles pattern $(pnames) '$(patterns[$(pnames)])' => '$(found_string[$(pnames)])'"; 71} 72 73 74####################################################### 75 76bundle agent check 77{ 78 vars: 79 "expected[a]" string => "$(G.testdir)/a,$(G.testdir)/d,$(G.testdir)/g"; 80 windows:: 81 "expected[b]" string => "$(G.testdir)/a,$(G.testdir)/bc,$(G.testdir)/d,$(G.testdir)/g,$(G.testdir)/klm"; 82 !windows:: 83 "expected[b]" string => "$(G.testdir)/a,$(G.testdir)/bc,$(G.testdir)/d,$(G.testdir)/g,$(G.testdir)/klm,$(G.testdir)/tu"; 84 85 any:: 86 "expected[c]" string => "$(G.testdir)/d/e,$(G.testdir)/g/h"; 87 "expected[d]" string => "$(G.testdir)/a,$(G.testdir)/bc"; 88 "expected[e]" string => ""; 89 90 !windows:: 91 "expected[f]" string => "$(G.testdir)/tu/*"; 92 "expected[g]" string => "$(G.testdir)/a,$(G.testdir)/bc,$(G.testdir)/d,$(G.testdir)/g,$(G.testdir)/klm,$(G.testdir)/tu,$(G.testdir)/d/e,$(G.testdir)/g/h,$(G.testdir)/klm/nop,$(G.testdir)/tu/*,$(G.testdir)/d/e/f,$(G.testdir)/g/h/i,$(G.testdir)/klm/nop/qrs,$(G.testdir)/g/h/i/j"; 93 "expected[h]" string => "$(G.testdir)/g/h/i/j"; 94 # relative paths are skipped, thus return empty list 95 "expected[relative_path_1]" string => ""; 96 "expected[relative_path_2]" string => ""; 97 "expected[relative_path_3]" string => ""; 98 99 any:: 100 "expects" slist => getindices("expected"); 101 102 "fstring" slist => getindices("test.found_string"); 103 104 "joint_condition" string => join(".", "expects"); 105 106 classes: 107 "$(expects)" expression => strcmp("$(test.found_string[$(expects)])", "$(expected[$(expects)])"); 108 "ok" expression => "$(joint_condition)"; 109 110 reports: 111 DEBUG:: 112 "pattern $(expects) matches as expected: '$(expected[$(expects)])'" 113 ifvarclass => "$(expects)"; 114 115 "pattern $(expects) does NOT match expected: '$(test.found_string[$(expects)])' != '$(expected[$(expects)])'" 116 ifvarclass => "!$(expects)"; 117 118 ok:: 119 "$(this.promise_filename) Pass"; 120 !ok:: 121 "$(this.promise_filename) FAIL"; 122} 123