From 60b6978f7aba0460e2c0b9be8e3a61f0807cd245 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Mon, 4 May 2026 22:40:40 +0200 Subject: [PATCH 1/5] Added test for invalid syntax in macros Signed-off-by: Ole Herman Schumacher Elgesem --- .../if_invalid_syntax_in_macro.sub.x.cf | 28 ++++++++++++++ .../if_invalid_syntax_in_macro_parent.cf | 37 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro.sub.x.cf create mode 100644 tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro_parent.cf diff --git a/tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro.sub.x.cf b/tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro.sub.x.cf new file mode 100644 index 0000000000..37b91f3f5f --- /dev/null +++ b/tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro.sub.x.cf @@ -0,0 +1,28 @@ +@if feature(ABCD) + This text should never be seen, it's completely ignored +@endif +@if feature(ABCD) + Nor this + Not this either +@endif +@if feature(ABCD) + Nothing should be seen here really + Who knows, perhaps this text doesn't exist..? +@endif + +@if minimum_version(300.600) + This text should never be seen, it's completely ignored +@endif + +@if minimum_version(300.600) + Some new function here... +@should_pass + bundle agent netgroup(@netgroup_list) + more text... +@endif + +bundle agent __main__ +{ + reports: + "$(this.promise_filename) Pass"; +} diff --git a/tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro_parent.cf b/tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro_parent.cf new file mode 100644 index 0000000000..d8d38d72c0 --- /dev/null +++ b/tests/acceptance/00_basics/macros/if_invalid_syntax_in_macro_parent.cf @@ -0,0 +1,37 @@ +###################################################### +# +# Test that macros correctly skip content +# even when it is invalid syntax +# +##################################################### +body common control +{ + inputs => { "../../default.sub.cf" }; + bundlesequence => { default("$(this.promise_filename)") }; +} + +bundle agent init +{ +} + +bundle agent check +{ + methods: + # Note: dcs_passif_output expects first argument to be regexp. + # To convert Windows-style path (with backslashes) to a regex which will match this path, + # we need to convert all backslashes to double-backslashes. + # In the command below, each backslash is escaped twice: + # once for regex, and once for CFEngine string parser. + "check" + usebundle => dcs_passif_output( + regex_replace( + ".*$(this.promise_dirname)$(const.dirsep)if_invalid_syntax_in_macro.sub.x.cf Pass.*", + "\\\\", + "\\\\\\\\", + "g" + ), + ".*FAIL.*", + "$(sys.cf_agent) -D AUTO -Kf -f $(this.promise_dirname)$(const.dirsep)if_invalid_syntax_in_macro.sub.x.cf", + $(this.promise_filename) + ); +} From d93f71ff279d60bf98a2328d9be91efe9790b3d1 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Mon, 4 May 2026 23:21:09 +0200 Subject: [PATCH 2/5] testall: Skipped .sub.x.cf files Signed-off-by: Ole Herman Schumacher Elgesem --- tests/acceptance/testall | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/testall b/tests/acceptance/testall index f62b7652fa..0959688b33 100755 --- a/tests/acceptance/testall +++ b/tests/acceptance/testall @@ -316,6 +316,11 @@ runtest() { printf "$TEST " fi + case "$TEST" in + *.sub.cf) echo "Not a test - file for subagent execution" && exit 1 ;; + *.sub.x.cf) echo "Not a test - file for subagent execution" && exit 1 ;; + esac + case "$TEST" in *.x.cf) TEST_TYPE=errorexit && EXTRATEXT='(should exit with non-zero, but not crash)' ;; @@ -1059,13 +1064,13 @@ then ALL_TESTS="$ALL_TESTS${ALL_TESTS:+ }$test" elif [ -d $test ] then - ALL_TESTS="$ALL_TESTS${ALL_TESTS:+ }$(find "$test" -name workdir -prune -o -name '*.cf' -and -not -name '*.sub.cf' -print | sort)" + ALL_TESTS="$ALL_TESTS${ALL_TESTS:+ }$(find "$test" -name workdir -prune -o -name '*.cf' -and -not -name '*.sub.cf' -and -not -name '*.sub.x.cf' -print | sort)" else echo "Unable to open test file/directory: $test" fi done else - ALL_TESTS="$ALL_TESTS${ALL_TESTS:+ }$(find . \( -name selftest -o -name workdir \) -prune -o -name '*.cf' -and -not -name '*.sub.cf' -print | sort)" + ALL_TESTS="$ALL_TESTS${ALL_TESTS:+ }$(find . \( -name selftest -o -name workdir \) -prune -o -name '*.cf' -and -not -name '*.sub.cf' -and -not -name '*.sub.x.cf' -print | sort)" fi for addtest in $ALL_TESTS From 0c3420a924a6e4b01bbf493002da55098dc05c02 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Mon, 4 May 2026 23:27:44 +0200 Subject: [PATCH 3/5] Renamed failsafe test sub policy file Signed-off-by: Ole Herman Schumacher Elgesem --- tests/acceptance/23_failsafe/failsafe_created_on_parse_error.cf | 2 +- .../{invalid_syntax.cf.sub => invalid_syntax.sub.x.cf} | 0 tests/acceptance/23_failsafe/preexisting_failsafe_preserved.cf | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/acceptance/23_failsafe/{invalid_syntax.cf.sub => invalid_syntax.sub.x.cf} (100%) diff --git a/tests/acceptance/23_failsafe/failsafe_created_on_parse_error.cf b/tests/acceptance/23_failsafe/failsafe_created_on_parse_error.cf index 84e4397d19..ed5793ab00 100644 --- a/tests/acceptance/23_failsafe/failsafe_created_on_parse_error.cf +++ b/tests/acceptance/23_failsafe/failsafe_created_on_parse_error.cf @@ -20,7 +20,7 @@ bundle agent init bundle agent test { commands: - "$(sys.cf_agent) -f $(this.promise_dirname)/invalid_syntax.cf.sub"; + "$(sys.cf_agent) -f $(this.promise_dirname)/invalid_syntax.sub.x.cf"; # TODO this sub-agent fails to run invalid_syntax.cf and writes # failsafe.cf, which then executes. The execute bit is diff --git a/tests/acceptance/23_failsafe/invalid_syntax.cf.sub b/tests/acceptance/23_failsafe/invalid_syntax.sub.x.cf similarity index 100% rename from tests/acceptance/23_failsafe/invalid_syntax.cf.sub rename to tests/acceptance/23_failsafe/invalid_syntax.sub.x.cf diff --git a/tests/acceptance/23_failsafe/preexisting_failsafe_preserved.cf b/tests/acceptance/23_failsafe/preexisting_failsafe_preserved.cf index d16184e657..d2b623f9c3 100644 --- a/tests/acceptance/23_failsafe/preexisting_failsafe_preserved.cf +++ b/tests/acceptance/23_failsafe/preexisting_failsafe_preserved.cf @@ -22,7 +22,7 @@ bundle agent init bundle agent test { commands: - "$(sys.cf_agent) -f $(this.promise_dirname)/invalid_syntax.cf.sub"; + "$(sys.cf_agent) -f $(this.promise_dirname)/invalid_syntax.sub.x.cf"; } bundle agent check From 96d35e78c64a2c62928c4b299e7ba62edd278eeb Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Mon, 4 May 2026 23:27:53 +0200 Subject: [PATCH 4/5] Cleaned up macro tests Some of these are overlapping, have misleading comments, and are testing too much at the same time. We want to make them easier to read and understand, and put the parts specific to testing that you can put invalid / future syntax inside macros in its own test(s). Signed-off-by: Ole Herman Schumacher Elgesem --- tests/acceptance/00_basics/macros/if.cf | 67 ------------------- .../macros/if_eof_without_endif.x.cf | 5 +- .../macros/if_eof_without_endif2.x.cf | 5 +- .../acceptance/00_basics/macros/if_feature.cf | 26 ------- .../00_basics/macros/if_feature_nested.x.cf | 5 -- .../acceptance/00_basics/macros/if_ignore.cf | 30 --------- .../macros/if_ignore_with_addsign.cf | 30 --------- .../00_basics/macros/if_mismatched.x.cf | 5 -- .../00_basics/macros/if_multiple_endif.x.cf | 5 -- .../00_basics/macros/if_nested.x.cf | 5 -- .../acceptance/00_basics/macros/if_triple.cf | 5 -- 11 files changed, 6 insertions(+), 182 deletions(-) delete mode 100644 tests/acceptance/00_basics/macros/if_ignore.cf delete mode 100644 tests/acceptance/00_basics/macros/if_ignore_with_addsign.cf diff --git a/tests/acceptance/00_basics/macros/if.cf b/tests/acceptance/00_basics/macros/if.cf index 18e9041e62..8380a45f53 100644 --- a/tests/acceptance/00_basics/macros/if.cf +++ b/tests/acceptance/00_basics/macros/if.cf @@ -167,70 +167,3 @@ bundle agent check DEBUG.pass_not_expected:: "pass_not_expected"; } - -@if minimum_version(3.12) -@else -some invalid syntax here -body {} {}{}{{}} -@endif - -@if minimum_version(3) -@else -some invalid syntax here -body {} {}{}{{}} -@endif - -@if minimum_version(300.600) - -This text should never be seen, it's completely ignored -@endif - -@if minimum_version(300.600) - -Nor should this - -@endif - -@if minimum_version(300.600) - -Nor this - -Not this either - -@endif - -@if minimum_version(300.600) -Nothing should be seen here really - -Who knows, perhaps this text doesn't exist..? - -@endif - -@if maximum_version(3.6.0) -body files control { {} } -@endif - -@if between_versions(2.0, 3.0) -more invalid syntax -body body body body {{}};;:: -@endif - -@if between_versions(1, 3.6) -more invalid syntax -body body body body {{}};;:: -@endif - -@if at_version(2) -body invalid syntax -{{{reports:}}};;;::: -@endif - -@if before_version(3) -body invalid syntax -{{{reports:}}};;;::: -@endif - -@if after_version(3) -body invalid syntax -{{{reports:}}};;;::: -@endif diff --git a/tests/acceptance/00_basics/macros/if_eof_without_endif.x.cf b/tests/acceptance/00_basics/macros/if_eof_without_endif.x.cf index 8a0d250ef4..b3c7f048aa 100644 --- a/tests/acceptance/00_basics/macros/if_eof_without_endif.x.cf +++ b/tests/acceptance/00_basics/macros/if_eof_without_endif.x.cf @@ -1,6 +1,6 @@ ###################################################### # -# Test that @if works +# Test that @if without @endif errors (1) # ##################################################### @@ -21,4 +21,5 @@ bundle agent check @if minimum_version(300.100) -This text should never be seen, it's completely ignored +# Even when the if is false / ignored, we should still error when there +# is no endif before EOF diff --git a/tests/acceptance/00_basics/macros/if_eof_without_endif2.x.cf b/tests/acceptance/00_basics/macros/if_eof_without_endif2.x.cf index ec698e553b..0fa31c76fa 100644 --- a/tests/acceptance/00_basics/macros/if_eof_without_endif2.x.cf +++ b/tests/acceptance/00_basics/macros/if_eof_without_endif2.x.cf @@ -1,6 +1,6 @@ ###################################################### # -# Test that @if works +# Test that @if without @endif errors (2) # ##################################################### @@ -21,4 +21,5 @@ bundle agent check @if minimum_version(1.1) -# just testing for EOF +# Even when the if is true / included, we should still error when there +# is no endif before EOF diff --git a/tests/acceptance/00_basics/macros/if_feature.cf b/tests/acceptance/00_basics/macros/if_feature.cf index 954acb1388..4ad91f1d2c 100644 --- a/tests/acceptance/00_basics/macros/if_feature.cf +++ b/tests/acceptance/00_basics/macros/if_feature.cf @@ -45,29 +45,3 @@ bundle agent check "not_expected", $(this.promise_filename)); } - -@if feature(ABCD) - -This text should never be seen, it's completely ignored -@endif - -@if feature(ABCD) - -Nor should this - -@endif - -@if feature(ABCD) - -Nor this - -Not this either - -@endif - -@if feature(ABCD) -Nothing should be seen here really - -Who knows, perhaps this text doesn't exist..? - -@endif diff --git a/tests/acceptance/00_basics/macros/if_feature_nested.x.cf b/tests/acceptance/00_basics/macros/if_feature_nested.x.cf index 8d58d5d284..e340c32bb4 100644 --- a/tests/acceptance/00_basics/macros/if_feature_nested.x.cf +++ b/tests/acceptance/00_basics/macros/if_feature_nested.x.cf @@ -40,8 +40,3 @@ bundle agent check "not_expected", $(this.promise_filename)); } - -@if minimum_version(300.600) - -This text should never be seen, it's completely ignored -@endif diff --git a/tests/acceptance/00_basics/macros/if_ignore.cf b/tests/acceptance/00_basics/macros/if_ignore.cf deleted file mode 100644 index be4c8df67a..0000000000 --- a/tests/acceptance/00_basics/macros/if_ignore.cf +++ /dev/null @@ -1,30 +0,0 @@ -###################################################### -# -# Test that @if works for greater versions -# -##################################################### - -body common control -{ - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; - version => "1.0"; -} - -bundle common test -{ -@if minimum_version(300.600) - Some new function here... - - - more text... -@endif -} - -bundle agent check -{ - methods: - "" usebundle => dcs_passif_expected("cfengine", - "", - $(this.promise_filename)); -} diff --git a/tests/acceptance/00_basics/macros/if_ignore_with_addsign.cf b/tests/acceptance/00_basics/macros/if_ignore_with_addsign.cf deleted file mode 100644 index 24e96416fd..0000000000 --- a/tests/acceptance/00_basics/macros/if_ignore_with_addsign.cf +++ /dev/null @@ -1,30 +0,0 @@ -###################################################### -# -# Test that @if works for greater versions -# -##################################################### - -body common control -{ - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; - version => "1.0"; -} - -bundle common test -{ -@if minimum_version(300.600) - Some new function here... -@should_pass - bundle agent netgroup(@netgroup_list) - more text... -@endif -} - -bundle agent check -{ - methods: - "" usebundle => dcs_passif_expected("cfengine", - "", - $(this.promise_filename)); -} diff --git a/tests/acceptance/00_basics/macros/if_mismatched.x.cf b/tests/acceptance/00_basics/macros/if_mismatched.x.cf index efcc3e97b9..76f0fca999 100644 --- a/tests/acceptance/00_basics/macros/if_mismatched.x.cf +++ b/tests/acceptance/00_basics/macros/if_mismatched.x.cf @@ -43,8 +43,3 @@ bundle agent check "not_expected", $(this.promise_filename)); } - -@if minimum_version(300.600) - -This text should never be seen, it's completely ignored -@endif diff --git a/tests/acceptance/00_basics/macros/if_multiple_endif.x.cf b/tests/acceptance/00_basics/macros/if_multiple_endif.x.cf index a209618af0..2adce3737c 100644 --- a/tests/acceptance/00_basics/macros/if_multiple_endif.x.cf +++ b/tests/acceptance/00_basics/macros/if_multiple_endif.x.cf @@ -37,8 +37,3 @@ bundle agent check "not_expected", $(this.promise_filename)); } - -@if minimum_version(300.600) - -This text should never be seen, it's completely ignored -@endif diff --git a/tests/acceptance/00_basics/macros/if_nested.x.cf b/tests/acceptance/00_basics/macros/if_nested.x.cf index d978fd890d..1f9e681ba4 100644 --- a/tests/acceptance/00_basics/macros/if_nested.x.cf +++ b/tests/acceptance/00_basics/macros/if_nested.x.cf @@ -38,8 +38,3 @@ bundle agent check "not_expected", $(this.promise_filename)); } - -@if minimum_version(300.600) - -This text should never be seen, it's completely ignored -@endif diff --git a/tests/acceptance/00_basics/macros/if_triple.cf b/tests/acceptance/00_basics/macros/if_triple.cf index 0f6dcb2c88..a9ae8a5b48 100644 --- a/tests/acceptance/00_basics/macros/if_triple.cf +++ b/tests/acceptance/00_basics/macros/if_triple.cf @@ -38,8 +38,3 @@ bundle agent check "$(sys.cf_agent) -D AUTO -Kf $(G.testdir)$(const.dirsep)test.cf", $(this.promise_filename)); } - -@if minimum_version(300.600.0) - -This text should never be seen, it's completely ignored -@endif From 8a255400f416f8b4746ee9aba936716ee08116e5 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Mon, 4 May 2026 23:31:55 +0200 Subject: [PATCH 5/5] cfengine format tests/acceptance/00_basics/macros/ Signed-off-by: Ole Herman Schumacher Elgesem --- tests/acceptance/00_basics/macros/if.cf | 143 ++++++++---------- .../acceptance/00_basics/macros/if_feature.cf | 26 ++-- .../00_basics/macros/if_feature_pam.cf | 9 +- .../00_basics/macros/if_on_first_line.cf | 10 +- .../acceptance/00_basics/macros/if_triple.cf | 42 ++--- 5 files changed, 113 insertions(+), 117 deletions(-) diff --git a/tests/acceptance/00_basics/macros/if.cf b/tests/acceptance/00_basics/macros/if.cf index 8380a45f53..95f604452a 100644 --- a/tests/acceptance/00_basics/macros/if.cf +++ b/tests/acceptance/00_basics/macros/if.cf @@ -3,167 +3,156 @@ # Test that @if works # ##################################################### - body common control { - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; - version => "1.0"; + inputs => { "../../default.sub.cf" }; + bundlesequence => { default("$(this.promise_filename)") }; + version => "1.0"; } bundle common test { @if minimum_version(3) classes: - "expected_3"; + "expected_3"; @else classes: - "not_expected_3"; + "not_expected_3"; @endif - @if minimum_version(3.7) classes: - "expected_3_7"; + "expected_3_7"; @else classes: - "not_expected_3_7"; + "not_expected_3_7"; @endif - @if minimum_version(3.6) classes: - "expected_3_6"; + "expected_3_6"; @else classes: - "not_expected_3_6"; + "not_expected_3_6"; @endif - @if minimum_version(2.100) classes: - "expected_2_100"; + "expected_2_100"; @else classes: - "not_xpected_2_100"; + "not_xpected_2_100"; @endif - @if minimum_version(300.700) classes: - "not_expected_300_700"; + "not_expected_300_700"; @else classes: - "expected_300_700"; + "expected_300_700"; @endif - @if maximum_version(3.0) - classes: - "not_expected_3_0"; + classes: + "not_expected_3_0"; @else - classes: - "expected_3_0"; + classes: + "expected_3_0"; @endif - @if maximum_version(4) - classes: - "expected_4"; + classes: + "expected_4"; @else - classes: - "not_expected_4"; + classes: + "not_expected_4"; @endif - @if maximum_version(4.0.0) - classes: - "expected_4_0_0"; + classes: + "expected_4_0_0"; @else - classes: - "not_expected_4_0_0"; + classes: + "not_expected_4_0_0"; @endif - @if between_versions(3.15.0, 4.0.0) - classes: - "expected_3_15_0_4_0_0"; + classes: + "expected_3_15_0_4_0_0"; @else - classes: - "not_expected_3_15_0_4_0_0"; + classes: + "not_expected_3_15_0_4_0_0"; @endif - @if between_versions(3.11, 3.12) - classes: - "not_expected_3_11_3_12"; + classes: + "not_expected_3_11_3_12"; @else - classes: - "expected_3_11_3_12"; + classes: + "expected_3_11_3_12"; @endif - @if before_version(4) - classes: - "expected_before_version_4"; + classes: + "expected_before_version_4"; @else - classes: - "not_expected_before_version_4"; + classes: + "not_expected_before_version_4"; @endif - @if before_version(3) - classes: - "not_expected_before_version_3"; + classes: + "not_expected_before_version_3"; @else - classes: - "expected_before_version_3"; + classes: + "expected_before_version_3"; @endif - @if at_version(3) - classes: - "expected_at_version_3"; + classes: + "expected_at_version_3"; @else - classes: - "not_expected_at_version_3"; + classes: + "not_expected_at_version_3"; @endif - @if at_version(2) - classes: - "not_expected_at_version_2"; + classes: + "not_expected_at_version_2"; @else - classes: - "expected_at_version_2"; + classes: + "expected_at_version_2"; @endif - @if after_version(2) - classes: - "expected_after_version_2"; + classes: + "expected_after_version_2"; @else - classes: - "not_expected_after_version_2"; + classes: + "not_expected_after_version_2"; @endif - @if after_version(3) - classes: - "not_expected_after_version_3"; + classes: + "not_expected_after_version_3"; @else - classes: - "expected_after_version_3"; + classes: + "expected_after_version_3"; @endif } bundle agent check { vars: - "expected_classes" slist => classesmatching("expected.*"); + "expected_classes" slist => classesmatching("expected.*"); "not_expected_classes" slist => classesmatching("not_expected.*"); - "expected_length" int => length("expected_classes"); - "not_expected_length" int => length("not_expected_classes"); + "expected_length" int => length("expected_classes"); + "not_expected_length" int => length("not_expected_classes"); + classes: - "pass_expected" if => strcmp("$(expected_length)", "16"); + "pass_expected" if => strcmp("$(expected_length)", "16"); "pass_not_expected" if => strcmp("$(not_expected_length)", "0"); "ok" and => { "pass_expected", "pass_not_expected" }; + methods: ok:: "" usebundle => dcs_pass($(this.promise_filename)); + reports: DEBUG:: "Expected classes: $(expected_classes)"; "Not expected classes: $(not_expected_classes)"; "Expected length: $(expected_length)"; "Not expected length: $(not_expected_length)"; + DEBUG.pass_expected:: "pass_expected"; + DEBUG.pass_not_expected:: "pass_not_expected"; } diff --git a/tests/acceptance/00_basics/macros/if_feature.cf b/tests/acceptance/00_basics/macros/if_feature.cf index 4ad91f1d2c..e2f0d5fd7c 100644 --- a/tests/acceptance/00_basics/macros/if_feature.cf +++ b/tests/acceptance/00_basics/macros/if_feature.cf @@ -3,29 +3,26 @@ # Test that @if feature() works # ##################################################### - body common control { - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; - version => "1.0"; + inputs => { "../../default.sub.cf" }; + bundlesequence => { default("$(this.promise_filename)") }; + version => "1.0"; } bundle common test { @if feature(xml) classes: - "xml" expression => "any"; + "xml" expression => "any"; @endif - @if feature(yaml) classes: - "yaml" expression => "any"; + "yaml" expression => "any"; @endif - @if feature(unknown_123) classes: - "not_expected" expression => "any"; + "not_expected" expression => "any"; @endif } @@ -34,14 +31,19 @@ bundle agent check vars: !feature_yaml.!feature_xml:: "result" string => ""; + feature_yaml.!feature_xml:: "result" string => "yaml"; + !feature_yaml.feature_xml:: "result" string => "xml"; + feature_yaml.feature_xml:: "result" string => "yaml,xml"; + methods: - "" usebundle => dcs_passif_expected("$(result)", - "not_expected", - $(this.promise_filename)); + "" + usebundle => dcs_passif_expected( + "$(result)", "not_expected", $(this.promise_filename) + ); } diff --git a/tests/acceptance/00_basics/macros/if_feature_pam.cf b/tests/acceptance/00_basics/macros/if_feature_pam.cf index 1f8c3a6ab5..89d8ef756e 100644 --- a/tests/acceptance/00_basics/macros/if_feature_pam.cf +++ b/tests/acceptance/00_basics/macros/if_feature_pam.cf @@ -3,12 +3,11 @@ # Test that @if feature() and class guard works for pam # ##################################################### - body common control { - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; - version => "1.0"; + inputs => { "../../default.sub.cf" }; + bundlesequence => { default("$(this.promise_filename)") }; + version => "1.0"; } bundle common test @@ -24,11 +23,13 @@ bundle agent check @if feature(pam) feature_pam:: "$(this.promise_filename) Pass"; + !feature_pam:: "$(this.promise_filename) FAIL"; @else !feature_pam:: "$(this.promise_filename) Pass"; + feature_pam:: "$(this.promise_filename) FAIL"; @endif diff --git a/tests/acceptance/00_basics/macros/if_on_first_line.cf b/tests/acceptance/00_basics/macros/if_on_first_line.cf index 741db4b500..7284d2ab56 100644 --- a/tests/acceptance/00_basics/macros/if_on_first_line.cf +++ b/tests/acceptance/00_basics/macros/if_on_first_line.cf @@ -8,15 +8,13 @@ body common control { - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; - version => "1.0"; + inputs => { "../../default.sub.cf" }; + bundlesequence => { default("$(this.promise_filename)") }; + version => "1.0"; } bundle agent check { methods: - "" usebundle => dcs_passif_expected("any", - "", - $(this.promise_filename)); + "" usebundle => dcs_passif_expected("any", "", $(this.promise_filename)); } diff --git a/tests/acceptance/00_basics/macros/if_triple.cf b/tests/acceptance/00_basics/macros/if_triple.cf index a9ae8a5b48..6c21ef31d1 100644 --- a/tests/acceptance/00_basics/macros/if_triple.cf +++ b/tests/acceptance/00_basics/macros/if_triple.cf @@ -2,39 +2,45 @@ # # Test that @if works with patch level ##################################################### - body common control { - inputs => { "../../default.sub.cf" }; - bundlesequence => { default("$(this.promise_filename)") }; + inputs => { "../../default.sub.cf" }; + bundlesequence => { default("$(this.promise_filename)") }; } bundle agent init { files: - "$(G.testdir)$(const.dirsep)test.cf" - create => "true", - edit_template => "$(this.promise_filename).sub.template", - template_method => "mustache"; + "$(G.testdir)$(const.dirsep)test.cf" + create => "true", + edit_template => "$(this.promise_filename).sub.template", + template_method => "mustache"; } bundle agent test { meta: - "test_skip_needs_work" string => "windows"; + "test_skip_needs_work" string => "windows"; } bundle agent check { methods: - # Note: dcs_passif_output expects first argument to be regexp. - # To convert Windows-style path (with backslashes) to a regex which will match this path, - # we need to convert all backslashes to double-backslashes. - # In the command below, each backslash is escaped twice: - # once for regex, and once for CFEngine string parser. - "check" usebundle => dcs_passif_output(regex_replace(".*$(G.testdir)$(const.dirsep)test.cf Pass.*", - "\\\\", "\\\\\\\\", "g"), - ".*FAIL.*", - "$(sys.cf_agent) -D AUTO -Kf $(G.testdir)$(const.dirsep)test.cf", - $(this.promise_filename)); + # Note: dcs_passif_output expects first argument to be regexp. + # To convert Windows-style path (with backslashes) to a regex which will match this path, + # we need to convert all backslashes to double-backslashes. + # In the command below, each backslash is escaped twice: + # once for regex, and once for CFEngine string parser. + "check" + usebundle => dcs_passif_output( + regex_replace( + ".*$(G.testdir)$(const.dirsep)test.cf Pass.*", + "\\\\", + "\\\\\\\\", + "g" + ), + ".*FAIL.*", + "$(sys.cf_agent) -D AUTO -Kf $(G.testdir)$(const.dirsep)test.cf", + $(this.promise_filename) + ); }