Skip to content

Commit

Permalink
tests/dep_tree: Make sure we can't depend on ourselves
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Dec 9, 2024
1 parent 7802a39 commit d41ddf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for test in $(ls -p tests | grep -v /); do
rm -rf .bob $TEST_OUT
mkdir -p $TEST_OUT

echo -n "Running test $test... "
printf "Running test $test... "
sh tests/$test > /dev/null

if [ $? = 0 ]; then
Expand Down
25 changes: 21 additions & 4 deletions tests/dep_tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

# Test the internal 'bob dep-tree' command and dependency tree creation.

# TODO Extra tests: make sure we can't depend on ourselves (this is a circular dependency, right? Will this be caught by our circular dependency check?)
# We need a circular dependency check of course.

try() {
out=$(bob -C tests/deps dep-tree 2>&1)

Expand Down Expand Up @@ -82,7 +79,7 @@ cp tests/deps/build.circular.fl tests/deps/build.fl
out=$(generic_timeout 2 bob -C tests/deps dep-tree 2>&1)

if [ $? = 142 ]; then
echo "Timed out when attempting to create a circular dependency tree (should just fail): $out" >&2
echo "Timed out when attempting to create a circular dependency tree: $out" >&2
exit 1
fi

Expand All @@ -95,3 +92,23 @@ if ! echo $out | grep -q "<bob-dep-tree circular />"; then
echo "Circular dependency not detected." >&2
exit 1
fi

# Test that we can't depend on ourselves.

cp tests/deps/build.self.fl tests/deps/build.fl
out=$(generic_timeout 2 bob -C tests/deps dep-tree 2>&1)

if [ $? = 142 ]; then
echo "Timed out when attempting to create a self dependency tree: $out" >&2
exit 1
fi

if [ $? != 0 ]; then
echo "Failed when attempting to create a self dependency tree: $out" >&2
exit 1
fi

if ! echo $out | grep -q "<bob-dep-tree circular />"; then
echo "Self dependency not detected." >&2
exit 1
fi

0 comments on commit d41ddf1

Please sign in to comment.