From 030884a8ad9ec165fb5397bd235f8c6f98a41494 Mon Sep 17 00:00:00 2001 From: Aymeric Wibo Date: Sat, 7 Dec 2024 23:01:15 +0200 Subject: [PATCH] tests/dep_tree: Make sure dependency tree is created correctly --- .gitignore | 1 + tests/dep_tree.sh | 37 +++++++++++++++++++++++++++++++++++++ tests/deps/build.normal.fl | 9 +++++++++ tests/deps/dep1/build.fl | 8 ++++++++ tests/deps/dep2/build.fl | 4 ++++ 5 files changed, 59 insertions(+) create mode 100644 tests/dep_tree.sh create mode 100644 tests/deps/build.normal.fl create mode 100644 tests/deps/dep1/build.fl create mode 100644 tests/deps/dep2/build.fl diff --git a/.gitignore b/.gitignore index fe2e633b..ab1791c5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ compile_commands.json .bob .bootstrap .test-out +tests/deps/build.fl diff --git a/tests/dep_tree.sh b/tests/dep_tree.sh new file mode 100644 index 00000000..84d1e367 --- /dev/null +++ b/tests/dep_tree.sh @@ -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 diff --git a/tests/deps/build.normal.fl b/tests/deps/build.normal.fl new file mode 100644 index 00000000..c0fac01d --- /dev/null +++ b/tests/deps/build.normal.fl @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Aymeric Wibo + +import bob + +deps = [ + Dep.local("dep1"), + Dep.local("dep2"), +] diff --git a/tests/deps/dep1/build.fl b/tests/deps/dep1/build.fl new file mode 100644 index 00000000..08923fd8 --- /dev/null +++ b/tests/deps/dep1/build.fl @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Aymeric Wibo + +import bob + +deps = [ + Dep.local("../dep2"), +] diff --git a/tests/deps/dep2/build.fl b/tests/deps/dep2/build.fl new file mode 100644 index 00000000..4fbdbd63 --- /dev/null +++ b/tests/deps/dep2/build.fl @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2024 Aymeric Wibo + +import bob