#!/bin/sh

set -ev

echo $0

# This test ensures that strict will fail if we do not include in the
# facfile an input that is generated by another rule.

rm -rf $0.dir
mkdir $0.dir
cd $0.dir

cat > top.fac <<EOF
| echo foo > foo

| cp foo bar

| cp foo baz
< foo

EOF

git init
git add top.fac

if ${FAC:-../../fac} --strict &> fac.out; then
    cat fac.out
    echo this should fail for one reason or another
    exit 1
fi

cat fac.out

if ${FAC:-../../fac} --strict &> fac.out; then
    cat fac.out
    echo this should fail due to strictness
    exit 1
fi

cat fac.out
grep 'requires foo' fac.out

cat > top.fac <<EOF
| echo foo > foo

| cp foo bar
< foo

| cp foo baz
< foo

EOF

${FAC:-../../fac} --strict

grep foo bar

exit 0
