#! /bin/sh

# These tests check the evaluation of the 'recursive_fill_list' function to
# verify that for any package s that depends on t, that the library defined by
# package s occurs before that of package t

set -e

. ${srcdir}/common

export PKG_CONFIG_PATH
PKG_CONFIG_PATH="${srcdir}/dependencies"

# Shared dependency test.
RESULT="-la_dep_c -lb_dep_c -lc_dep"
run_test --libs a_dep_c b_dep_c
run_test --libs c_dep a_dep_c b_dep_c
run_test --libs a_dep_c c_dep b_dep_c
run_test --libs a_dep_c b_dep_c c_dep

# Redundancy test.
#
# Redundancy on the input line should not pass through.
RESULT="-la_dep_c -lb_dep_c -lc_dep"
run_test --libs a_dep_c a_dep_c b_dep_c
run_test --libs b_dep_c a_dep_c b_dep_c

# Diamond pattern test.
#
# One dependency of d depends on the other.
# Both dependencies of d depend on g
RESULT="-ld_dep_e_f -le_dep_g_f -lf_dep_g -lg_dep"
run_test --libs d_dep_e_f
RESULT="-ld_dep_f_e -le_dep_g_f -lf_dep_g -lg_dep"
run_test --libs d_dep_f_e

# Nested inclusion.
#
# Each package depends on all downsteam packages.
RESULT="-lh_dep_k_i_j -li_dep_k_j -lj_dep_k -lk_dep"
run_test --libs h_dep_k_i_j
run_test --libs h_dep_k_i_j i_dep_k_j
run_test --libs i_dep_k_j h_dep_k_i_j
run_test --libs k_dep j_dep_k i_dep_k_j h_dep_k_i_j
