Skip to content

Commit f702d3b

Browse files
committed
Test that findfiles() returns directories with a trailing slash when given a trailing slash
Prior to findfiles() fixes related to https://cfengine.com/blog/2025/change-in-behavior-findfiles/ findfiles() would return a trailing slash for directories when one was provided. This behavior was expected by users, but not tested for explicitly nor documented as an explicit behavior. Ticket: CFE-4623 Changelog: None
1 parent 92d3a90 commit f702d3b

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#######################################################
2+
#
3+
# Test that findfiles() returns trailing slash on directories when a trailing
4+
# slash is provided as input
5+
#
6+
#######################################################
7+
8+
body common control
9+
{
10+
inputs => { "../../default.cf.sub" };
11+
bundlesequence => { default("$(this.promise_filename)") };
12+
}
13+
14+
bundle agent test
15+
{
16+
meta:
17+
"test_soft_fail" string => "cfengine_3_21_8|cfengine_3_24_0|cfengine_3_24_1|cfengine_3_24_2|cfengine_3_24_3|cfengine_3_27_0",
18+
meta => { "CFE-4623" };
19+
20+
vars:
21+
"find_this_promise_dirname"
22+
slist => findfiles( "$(this.promise_dirname)/");
23+
}
24+
25+
bundle agent check
26+
{
27+
classes:
28+
29+
"ok"
30+
expression => regcmp( ".*[\\]$", $(test.find_this_promise_dirname) );
31+
# Windows uses backslash, so a better regular expression accounting for
32+
# that might be ".*[\\\/]$"
33+
34+
reports:
35+
ok::
36+
"$(this.promise_filename) Pass";
37+
38+
ok.(verbose_mode|inform_mode)::
39+
"test.find_this_promise_dirname ($(test.find_this_promise_dirname)) has a trailing slash";
40+
41+
!ok::
42+
"$(this.promise_filename) FAIL";
43+
44+
}

0 commit comments

Comments
 (0)