1#######################################################
2#
3# Test basename() with suffix removal
4#
5#######################################################
6
7body common control
8{
9      inputs => { "../../default.cf.sub" };
10      bundlesequence  => { default("$(this.promise_filename)") };
11      version => "1.0";
12}
13
14#######################################################
15
16bundle agent test
17{
18  vars:
19      # The tests starting with template will be tested with both types of
20      # directory separators on Windows.
21
22      "template_input[root]" string => "/";
23      "template_suffix[root]" string => "";
24      "template_expected[root]" string => "/";
25
26      "template_input[simple]" string => "/foo/bar.c";
27      "template_suffix[simple]" string => ".c";
28      "template_expected[simple]" string => "bar";
29
30      "template_input[rel_suffif]" string => "foo.xyz";
31      "template_suffix[rel_suffif]" string => ".xyz";
32      "template_expected[rel_suffif]" string => "foo";
33
34      "template_input[no_matching_suffix]" string => "/foo/bar";
35      "template_suffix[no_matching_suffix]" string => "baz";
36      "template_expected[no_matching_suffix]" string => "bar";
37
38      "template_input[same_suffix]" string => "foo";
39      "template_suffix[same_suffix]" string => "foo";
40      "template_expected[same_suffix]" string => "foo";
41
42      "template_input[sub_same_suffix]" string => "foo/bar";
43      "template_suffix[sub_same_suffix]" string => "bar";
44      "template_expected[sub_same_suffix]" string => "bar";
45
46      "template_keys" slist => getindices("template_input");
47
48    any::
49      "input[native_$(template_keys)]" string => "$(template_input[$(template_keys)])";
50      "expected[native_$(template_keys)]" string => "$(template_expected[$(template_keys)])";
51      "suffix[native_$(template_keys)]" string => "$(template_suffix[$(template_keys)])";
52
53      "keys" slist => getindices("input");
54
55      "actual[$(keys)]" string => basename("$(input[$(keys)])", "$(suffix[$suffix])");
56}
57
58#######################################################
59
60bundle agent check
61{
62  vars:
63      "keys" slist => { @(test.keys) };
64
65  classes:
66      "failed_cmp_$(keys)" not => strcmp(basename("$(test.input[$(keys)])", "$(test.suffix[$(keys)])"), "$(test.expected[$(keys)])");
67      "ok" not => classmatch("failed_cmp_.*");
68
69  reports:
70    DEBUG::
71      "'basename($(test.input[$(keys)]), $(test.suffix[$(keys)]))' = '$(test.actual[$(keys)])' != '$(test.expected[$(keys)])'"
72        ifvarclass => "failed_cmp_$(keys)";
73
74    ok::
75      "$(this.promise_filename) Pass";
76    !ok::
77      "$(this.promise_filename) FAIL";
78}
79