diff --git a/tests/acceptance/17_packages/11_old/unsafe/package-inventory.cf b/tests/acceptance/17_packages/11_old/unsafe/package-inventory.cf index 9d39338af8..67231156dd 100644 --- a/tests/acceptance/17_packages/11_old/unsafe/package-inventory.cf +++ b/tests/acceptance/17_packages/11_old/unsafe/package-inventory.cf @@ -89,10 +89,14 @@ bundle agent check vars: "inst" string => "$(sys.workdir)/state/software_packages.csv"; "inst_expr" string => "^($(p.name[1])|$(p.name[2])|$(p.name[3])),.*"; - "inst_matches" int => countlinesmatching("$(inst_expr)", "$(inst)"); + "inst_matches" + int => countlinesmatching("$(inst_expr)", "$(inst)"), + if => fileexists("$(inst)"); "upd" string => "$(sys.workdir)/state/software_patches_avail.csv"; "upd_expr" string => "^($(p.name[1])|$(p.name[2])|$(p.name[3])),.*"; - "upd_matches" int => countlinesmatching("$(upd_expr)", "$(upd)"); + "upd_matches" + int => countlinesmatching("$(upd_expr)", "$(upd)"), + if => fileexists("$(upd)"); classes: # Should match all packages except the second one. diff --git a/tests/acceptance/17_packages/packages-info.cf.sub b/tests/acceptance/17_packages/packages-info.cf.sub index 2840ddd9ca..978b789844 100644 --- a/tests/acceptance/17_packages/packages-info.cf.sub +++ b/tests/acceptance/17_packages/packages-info.cf.sub @@ -78,7 +78,8 @@ bundle agent clear_packages(key) commands: redhat|suse|sles:: - "$(paths.path[rpm]) -e --allmatches $(p.name[$(p.packages)]) $(output_sink)" + # Only remove installed packages, rpm -e fails on missing ones + "! $(paths.path[rpm]) -q $(p.name[$(p.packages)]) > $(G.dev_null) 2>&1 || $(paths.path[rpm]) -e --allmatches $(p.name[$(p.packages)]) $(output_sink)" contain => in_shell, comment => $(key); debian|sles:: diff --git a/tests/acceptance/30_custom_promise_types/20_depends_on.cf b/tests/acceptance/30_custom_promise_types/20_depends_on.cf index 4cf248d062..7429b55525 100644 --- a/tests/acceptance/30_custom_promise_types/20_depends_on.cf +++ b/tests/acceptance/30_custom_promise_types/20_depends_on.cf @@ -89,7 +89,9 @@ bundle agent check { vars: "expected" string => "CAEBD"; - "found" string => readfile("$(G.testfile)"); + "found" + string => readfile("$(G.testfile)"), + if => fileexists("$(G.testfile)"); classes: "ok" expression => strcmp("$(expected)", "$(found)"); diff --git a/tests/acceptance/30_custom_promise_types/21_with_attribute.cf b/tests/acceptance/30_custom_promise_types/21_with_attribute.cf index cf263e361f..93b20d797d 100644 --- a/tests/acceptance/30_custom_promise_types/21_with_attribute.cf +++ b/tests/acceptance/30_custom_promise_types/21_with_attribute.cf @@ -73,7 +73,9 @@ bundle agent check { vars: "expected" string => "abcdef"; - "found" string => readfile("$(G.testfile)"); + "found" + string => readfile("$(G.testfile)"), + if => fileexists("$(G.testfile)"); classes: "ok" expression => strcmp("$(expected)", "$(found)"); diff --git a/tests/acceptance/30_custom_promise_types/22_bodies.cf b/tests/acceptance/30_custom_promise_types/22_bodies.cf index 57878f45d1..e8d024750e 100644 --- a/tests/acceptance/30_custom_promise_types/22_bodies.cf +++ b/tests/acceptance/30_custom_promise_types/22_bodies.cf @@ -83,7 +83,9 @@ bundle agent check "expected" string => '{"example_body": {"alice": "1", "bob": "3", "charlie": "4"}}'; - "found" string => readfile("$(G.testfile)"); + "found" + string => readfile("$(G.testfile)"), + if => fileexists("$(G.testfile)"); classes: "ok" expression => strcmp("$(expected)", "$(found)"); diff --git a/tests/acceptance/30_custom_promise_types/22_single_evaluation.cf b/tests/acceptance/30_custom_promise_types/22_single_evaluation.cf index c935f1d766..3798b25270 100644 --- a/tests/acceptance/30_custom_promise_types/22_single_evaluation.cf +++ b/tests/acceptance/30_custom_promise_types/22_single_evaluation.cf @@ -72,7 +72,9 @@ bundle agent check { vars: "expected" string => "hello"; - "found" string => readfile("$(G.testfile)"); + "found" + string => readfile("$(G.testfile)"), + if => fileexists("$(G.testfile)"); classes: "ok" expression => strcmp("$(expected)", "$(found)"); diff --git a/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf b/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf index 9d3e5c608e..0ea12829a9 100644 --- a/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf +++ b/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf @@ -17,13 +17,17 @@ bundle agent test "/tmp/dummyfile" smth => "hello"; vars: - "content" string => readfile("/tmp/dummyfile"); + "content" + string => readfile("/tmp/dummyfile"), + if => fileexists("/tmp/dummyfile"); files: "/tmp/dummyfile" content => "ok"; vars: - "content" string => readfile("/tmp/dummyfile"); + "content" + string => readfile("/tmp/dummyfile"), + if => fileexists("/tmp/dummyfile"); classes: "ok" expression => strcmp("$(content)", "ok");