From d41ddf10bfbec3d76b1ccbc084568b71d48f2468 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Tue, 10 Dec 2024 00:15:53 +0100 Subject: [PATCH] tests/dep_tree: Make sure we can't depend on ourselves --- tests.sh | 2 +- tests/dep_tree.sh | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests.sh b/tests.sh index 56e1bb44..fc462166 100644 --- a/tests.sh +++ b/tests.sh @@ -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 diff --git a/tests/dep_tree.sh b/tests/dep_tree.sh index de67fe7e..95fc8b1c 100644 --- a/tests/dep_tree.sh +++ b/tests/dep_tree.sh @@ -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) @@ -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 @@ -95,3 +92,23 @@ if ! echo $out | grep -q ""; 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 ""; then + echo "Self dependency not detected." >&2 + exit 1 +fi