# Test a context defined in body classes with scope => bundle,
# check that the bundle context goes away after the bundle is done

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

bundle agent init
{
  vars:
      "dummy" string => "dummy";
}

bundle agent test
{
  methods:
    !pass_one::
      "whatever"
      usebundle => set_context("yes");
    pass_one::
      "whatever2"
      usebundle => set_context("no");
}

bundle agent set_context(doit)
{
  classes:
      "set_bundle_class" expression => strcmp(${doit}, "yes");

  processes:
    set_bundle_class::
      "$(G.true)"
      classes => bundle_class;

      "$(G.true)"
      classes => namespace_class;
}


body classes namespace_class
{
      scope => "namespace";
      promise_kept => { "pass_one" };
}

body classes bundle_class
{
      scope => "bundle";
      promise_kept => { "bundle_context" };
}

bundle agent check
{
  reports:
    !bundle_context::
      "$(this.promise_filename) Pass";
    bundle_context::
      "$(this.promise_filename) FAIL";
}
