#######################################################
#
# Test exec_program on file_select (issue 294) - test negative match on existing file
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
  vars:
    "find_this" string => "bibbetygargle";

  files:
    "$(G.testfile)"
      create => "true",
      edit_line => init_data;
}

bundle edit_line init_data
{
  insert_lines:
    "Gabba gabba hey!";
    "yibbity $(find_this) bletch";
    "torchecol bum adder";
}

#######################################################
bundle agent test
{
  vars:
    linux::
      "prefix" string => "";

    freebsd::
      "prefix" string => "/usr";

    !(linux|freebsd)::
      "prefix" string => "FIX ME";

  files:
    "$(G.testroot)"
      file_select => test_hunt("$(prefix)"),
      delete => test_delete;
}

body file_select test_hunt(prefix)
{
  exec_program => "$(G.grep) XX$(init.find_this)XX $(this.promiser)";
  file_result => "exec_program";
}

body delete test_delete
{
  dirlinks => "delete";
  rmdirs => "true";
}

#######################################################
bundle agent check
{
  classes:
    "ok" expression => fileexists("$(G.testfile)");

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

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

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