1body file control 2{ 3 inputs => { "../../default.cf.sub" }; 4} 5 6bundle agent main 7{ 8 methods: 9 "init,test,check,cleanup" 10 usebundle => default("$(this.promise_filename)") ; 11} 12 13bundle agent init 14{ 15 files: 16 17 # First we initialize some directories to iterate over and some files that 18 # will be renamed during the test 19 20 "$(G.testdir)/test/$(check.dirs)/incoming/$(check.files)" 21 create => "true"; 22} 23 24bundle agent test 25{ 26 meta: 27 28 "description" 29 string => "Test that files can be renamed using regular expression 30 matches from the promiser"; 31 32 "test_soft_fail" 33 string => "any", 34 meta => { "CFE-2879" }; 35 36 files: 37 38 # We promise that the target is a copy of the source file Since preserve 39 # is set to false, we expect the original permissions on the target file 40 # to remain unchanged. 41 42 "$(G.testdir)/test/$(check.dirs)/incoming/((?!.*renamed)[a-z]*)" 43 rename => to( "$(G.testdir)/test/$(check.dirs)/incoming/$(match.1)_renamed" ); 44 45} 46 47body rename to(file) 48{ 49 newname => "$(file)"; 50} 51 52bundle agent check 53{ 54 vars: 55 "dirs" 56 slist => { "knuth", "lamport", "turing" }; 57 58 "files" 59 slist => { "one", "two", "three" }; 60 61 # Append _renamed to each of the files 62 "expected_files" slist => maplist( "$(this)_renamed", files ); 63 64 "expected_paths" slist => { 65 "$(G.testdir)/test/knuth/incoming/one_renamed", 66 "$(G.testdir)/test/knuth/incoming/two_renamed", 67 "$(G.testdir)/test/knuth/incoming/three_renamed", 68 "$(G.testdir)/test/lamport/incoming/one_renamed", 69 "$(G.testdir)/test/lamport/incoming/two_renamed", 70 "$(G.testdir)/test/lamport/incoming/three_renamed", 71 "$(G.testdir)/test/turing/incoming/one_renamed", 72 "$(G.testdir)/test/turing/incoming/two_renamed", 73 "$(G.testdir)/test/turing/incoming/three_renamed", 74 }; 75 76 classes: 77 "all_expected_files_exist" 78 expression => filesexist( @(expected_paths) ); 79 80 methods: 81 82 "Pass or Fail" 83 usebundle => dcs_passif( "all_expected_files_exist", 84 $(this.promise_filename)); 85 86 reports: 87 DEBUG|EXTRA:: 88 "Expected path exists '$(expected_paths)'" 89 if => fileexists( $(expected_paths) ); 90 "Expected path MISSING '$(expected_paths)'" 91 unless => fileexists( $(expected_paths) ); 92} 93