Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/acceptance/01_vars/02_functions/CFE-4623.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#######################################################
#
# Test that findfiles() returns trailing slash on directories when a trailing
# slash is provided as input
#
#######################################################

body common control
{
inputs => { "../../default.cf.sub" };
bundlesequence => { default("$(this.promise_filename)") };
}

bundle agent test
{
meta:
"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",
meta => { "CFE-4623" };

vars:
"find_this_promise_dirname"
slist => findfiles( "$(this.promise_dirname)/");
}

bundle agent check
{
classes:

"ok"
expression => regcmp( ".*[\\]$", $(test.find_this_promise_dirname) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From GitHub Actions:

error: Regular expression error: 'missing terminating ] for character class' in expression '.*[\]$' (offset: 6)

I think what is happening here is that \\ becomes \, then the ] gets escaped.

I'm not sure if you need a character set (i.e., []) here at all, since you're only matching one character.

# Windows uses backslash, so a better regular expression accounting for
# that might be ".*[\\\/]$"

reports:
ok::
"$(this.promise_filename) Pass";

ok.(verbose_mode|inform_mode)::
"test.find_this_promise_dirname ($(test.find_this_promise_dirname)) has a trailing slash";

!ok::
"$(this.promise_filename) FAIL";

}
Loading