# file      : tests/fetch.testscript
# license   : MIT; see accompanying LICENSE file

.include common.testscript project.testscript

config_cxx = [cmdline] cc config.cxx=$quote($recall($cxx.path) $cxx.config.mode, true)

new    += 2>!
init   += $config_cxx -d prj 2>!
status += --all -d prj
deinit += -d prj

: dependency
:
{
  $clone_prj;
  $init -C @cfg &prj-cfg/***;

  $new -t lib libbar &libbar/*** 2>!;
  $new -t lib libfoo &libfoo/*** 2>!;

  cat <<EOI >+prj/repositories.manifest;
    :
    role: prerequisite
    location: ../libfoo
    type: dir
    :
    role: complement
    location: ../libbar
    type: dir
    EOI

  cat <<EOI >+prj/manifest;
    depends: libfoo
    depends: libbar
    EOI

  $* 2>>/~%EOE%;
    %fetching dir:.+/libbar \(complements dir:.+/prj\)%
    %fetching dir:.+/libfoo \(prerequisite of dir:.+/prj\)%
    EOE

  $status libfoo libbar >>~%EOO%;
    %libfoo available \[.+\]%
    %libbar available .+%
    EOO

  $deinit 2>>/"EOE"
    deinitializing in project $~/prj/
    synchronizing:
      drop prj
    EOE
}
