Skip to content

Commit

Permalink
tests/dep_tree: Make sure dependency tree is created correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Dec 7, 2024
1 parent 374827c commit 030884a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ compile_commands.json
.bob
.bootstrap
.test-out
tests/deps/build.fl
37 changes: 37 additions & 0 deletions tests/dep_tree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
set -e

. tests/common.sh

# 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.
# Also a check for a dependency which don't exit.
# And a check that we're caching dependencies correctly (i.e. same version same cache, different versions different cache).
# Also also a check that we don't have the same dependency twice in our list.

# Test dependency tree creation.

cp tests/deps/build{.normal,}.fl
rm -rf tests/deps/.bob tests/deps/dep{1,2}/.bob
bob -C tests/deps dep-tree >/dev/null 2>/dev/null

DEPS_TREE_PATH=tests/deps/.bob/deps.tree

if [ ! -f $DEPS_TREE_PATH ]; then
echo "Dependency tree not created." >&2
exit 1
fi

DEP1=$(find ~/.cache/bob/deps -name "*dep1*")
DEP2=$(find ~/.cache/bob/deps -name "*dep2*")

echo "$DEP1" > $DEPS_TREE_PATH.expected
echo "\t$DEP2" >> $DEPS_TREE_PATH.expected
echo "$DEP2" >> $DEPS_TREE_PATH.expected

if ! diff $DEPS_TREE_PATH $DEPS_TREE_PATH.expected; then
echo "Dependency tree differed to the one expected." >&2
exit 1
fi
9 changes: 9 additions & 0 deletions tests/deps/build.normal.fl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Aymeric Wibo

import bob

deps = [
Dep.local("dep1"),
Dep.local("dep2"),
]
8 changes: 8 additions & 0 deletions tests/deps/dep1/build.fl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Aymeric Wibo

import bob

deps = [
Dep.local("../dep2"),
]
4 changes: 4 additions & 0 deletions tests/deps/dep2/build.fl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 Aymeric Wibo

import bob

0 comments on commit 030884a

Please sign in to comment.