#######################################################
#
# Issue 377
#
#######################################################

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

bundle agent init
{
  vars:
      "files" slist => { "1", "2", "3" };

  files:
      "$(G.testdir)/."
      create => "true";

      "$(G.testdir)/$(files)"
      copy_from => init_copy("$(G.etc_group)");
}

body copy_from init_copy(file)
{
      source => "$(file)";
}

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

bundle agent test
{
  vars:
      "counter" string => "$(G.testdir)/counter";

  files:
      "$(G.testdir)"
      transformer => "/bin/sh -c 'echo $(this.promiser) >> $(counter)'",
      file_select => test_plain,
      depth_search => test_recurse;
}

body file_select test_plain
{
      file_types => { "plain" };
      file_result => "file_types|bfd.pms.wtf!";	# Illegal test names
}

body depth_search test_recurse
{
      depth => "inf";
}

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

bundle agent check
{
  vars:
      "count" string => execresult("$(G.wc) $(test.counter)", "noshell");

  classes:
      "ok" expression => regcmp("\s*3\s.*", "$(count)");

  reports:
    DEBUG::
      "3 transformations expected, saw '$(count)'";
    ok::
      "$(this.promise_filename) Pass";
    !ok::
      "$(this.promise_filename) FAIL";
}
