# -*- sh -*-
# vim: syntax=sh
#
# This script should be sourced at the beginning of each script
# you can specify flavours supported by test script by passing them as
# parameters to this script (you can use regexes).
#
# It exports variable $FLAVOUR which should be added to verification command.

. lib/util

test -z "$TEST_FLAVOUR" && return 0

if [ $# -gt 0 ]; then
    OK=0
    for p in "$@"; do
        echo "$TEST_FLAVOUR" | grep -q "$p" && OK=1
    done
    test $OK -eq 0 && skip
fi

test $TEST_FLAVOUR = vanilla && return 0

export FLAVOUR=""
for f in `echo $TEST_FLAVOUR | sed 's/+/ /'`; do
    if [ $f = shared ]; then
        FLAVOUR="$FLAVOUR --shared"
    elif [ $f = part ]; then
        FLAVOUR="$FLAVOUR --no-shared"
    elif [ $f = none ]; then
        FLAVOUR="$FLAVOUR --compression=none"
    elif [ $f = tree ]; then
        FLAVOUR="$FLAVOUR --compression=tree"
        test "$STORE_COMPRESS" = "ON" || skip
    else
        echo "ERROR: unknown test flavour '$f'" >&2
        return 1
    fi
done
