-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
ENT-5850: Modified classesmatching() function to search parent bundles with inherit => true (3.18)
- Loading branch information
Showing
6 changed files
with
181 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/acceptance/02_classes/02_functions/classesmatching_inherit.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
bundle agent __main__ | ||
{ | ||
classes: | ||
"defined_in_parent" expression => "cfengine"; | ||
|
||
methods: | ||
"ENT-5850" | ||
usebundle => ENT_5850, | ||
inherit => "true"; | ||
} | ||
|
||
bundle agent ENT_5850 | ||
{ | ||
vars: | ||
"c_matching" | ||
slist => classesmatching(".*"); | ||
"c_matching_defined_in_parent" | ||
slist => classesmatching("defined_in_parent"); | ||
|
||
classes: | ||
"defined_here" expression => "cfengine"; | ||
|
||
reports: | ||
"$(this.promise_filename) Pass" | ||
if => some( "defined_in_parent", c_matching); | ||
|
||
"$(this.promise_filename) FAIL $(this.promise_filename)$(const.n)Could not find class 'defined_in_parent' in classesmatching() but it's defined" | ||
if => and( not( some( "defined_in_parent", c_matching) ), | ||
defined_in_parent | ||
); | ||
|
||
"Classes found by classesmatching() starting with 'defined' $(with)" | ||
with => join( ", ", classesmatching("defined.*") ); | ||
|
||
"'defined_here' is defined" if => "defined_here"; | ||
"'defined_in_parent' is defined" if => "defined_in_parent"; | ||
"Running CFEngine: $(sys.cf_version)"; | ||
} |
65 changes: 65 additions & 0 deletions
65
tests/acceptance/02_classes/02_functions/classesmatching_inherit_2.cf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
bundle agent common | ||
{ | ||
vars: | ||
"logfile" string => "$(this.promise_dirname)$(const.dirsep)defined_classes.log"; | ||
} | ||
|
||
bundle agent __main__ | ||
{ | ||
classes: "defined_in_main"; | ||
methods: | ||
"init"; | ||
"first" inherit => "true"; | ||
"check"; | ||
} | ||
|
||
bundle agent init | ||
{ | ||
files: | ||
"$(common.logfile)" | ||
delete => tidy; | ||
} | ||
|
||
bundle agent first | ||
{ | ||
classes: "defined_in_first"; | ||
methods: "second" inherit => "true"; | ||
} | ||
|
||
bundle agent second | ||
{ | ||
classes: "defined_in_second"; | ||
methods: "third" inherit => "true"; | ||
} | ||
|
||
bundle agent third | ||
{ | ||
vars: | ||
"defined_classes" slist => classesmatching("defined.*"); | ||
|
||
reports: | ||
"defined_classes: $(defined_classes)" | ||
report_to_file => "$(common.logfile)"; | ||
} | ||
|
||
bundle agent check | ||
{ | ||
vars: | ||
"expected" string => concat("defined_classes: defined_in_main$(const.n)", | ||
"defined_classes: defined_in_first$(const.n)", | ||
"defined_classes: defined_in_second$(const.n)"); | ||
"actual" string => readfile("$(common.logfile)", inf); | ||
|
||
reports: | ||
"$(this.promise_filename) Pass" | ||
if => strcmp($(expected), $(actual)); | ||
|
||
"$(this.promise_filename) FAIL" | ||
if => not(strcmp($(expected), $(actual))); | ||
} | ||
|
||
body delete tidy | ||
{ | ||
dirlinks => "delete"; | ||
rmdirs => "true"; | ||
} |