#######################################################
#
# Test matching EOF in file where end selector in region don't matches
# anything and local edit_line 'select_end_match_eof' option is
# overriding global body common control. 
#
#######################################################

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

body agent control
{
      select_end_match_eof => "true";
}

#######################################################

bundle agent init
{
  vars:
      "actual" string => "[quux]
bar
foo
";

      "expected" string => "[quux]
bar
foo
";

      "files" slist => { "actual", "expected" };

  files:
      "$(G.testfile).$(files)"
      create => "true",
      edit_line => init_insert("$(init.$(files))"),
      edit_defaults => init_empty;
}

bundle edit_line init_insert(str)
{
  insert_lines:
      "$(str)";
}

body edit_defaults init_empty
{
      empty_file_before_editing => "true";
}

#######################################################

bundle agent test
{
  files:
      "$(G.testfile).actual"
      edit_line => example_edit_line;
}

bundle edit_line example_edit_line
{
  insert_lines:
      "foo"
      select_region => example_select,
      location => example_location;
}

body select_region example_select
{
      select_start => "\[quux\]";
      select_end => "\[.*\]";
      select_end_match_eof => "false";
}

body location example_location
{
      select_line_matching => "bar";
      before_after => "after";
}

#######################################################

bundle agent check
{
  methods:
      "any" usebundle => dcs_check_diff("$(G.testfile).actual",
                                            "$(G.testfile).expected",
                                            "$(this.promise_filename)");
}

### PROJECT_ID: core
### CATEGORY_ID: 27
