Skip to content

Commit 2c721ed

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 2c721ed

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)