tests: try to autodetect directory better

Ignore mkosi.builddir. In the future we can also add other patterns
if necessary.

run-intergration-tests.sh is updated to use the new script, and modified
to work from arbitrary directory.

Follow-up for #7494.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-12-06 15:09:54 +01:00
parent 4fb55f18ea
commit ded65775a2
8 changed files with 40 additions and 25 deletions

View File

@ -1,14 +0,0 @@
# Try to guess the build directory:
# we look for subdirectories of ../.. that look like ninja build dirs.
ifeq ($(BUILD_DIR),)
dirs = $(dir $(wildcard ../../*/.ninja_log))
ifeq ($(dirs),)
$(error Cannot guess build dir, set BUILD_DIR)
endif
ifneq ($(firstword $(dirs)),$(dirs))
$(warning Candidates: $(dirs))
$(error Too many build dirs to pick from, set BUILD_DIR)
endif
BUILD_DIR=$(dirs)
endif

View File

@ -1,4 +1,4 @@
include ../Makefile.guess
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
all setup clean run:
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

View File

@ -1,4 +1,4 @@
include ../Makefile.guess
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
all setup run:
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

View File

@ -1,4 +1,4 @@
include ../Makefile.guess
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
all setup clean run:
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

View File

@ -1,4 +1,4 @@
include ../Makefile.guess
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
all setup clean run:
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

View File

@ -1,4 +1,4 @@
include ../Makefile.guess
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
all setup clean run:
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

View File

@ -1,21 +1,19 @@
#!/bin/bash -e
if ! test -d ../build ; then
echo "Expected build directory in ../build, but couldn't find it." >&2
exit 1
fi
BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
ninja -C ../build
ninja -C "$BUILD_DIR"
declare -A results
RESULT=0
FAILURES=0
cd "$(dirname "$0")"
for TEST in TEST-??-* ; do
echo -e "\n--x-- Starting $TEST --x--"
set +e
make -C "$TEST" BUILD_DIR=$(pwd)/../build clean setup run
make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean setup run
RESULT=$?
set -e
echo "--x-- Result of $TEST: $RESULT --x--"

31
tools/find-build-dir.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh -e
# Try to guess the build directory:
# we look for subdirectories of the parent directory that look like ninja build dirs.
if [ -n "$BUILD_DIR" ]; then
echo "$(realpath "$BUILD_DIR")"
exit 0
fi
root="$(dirname "$(realpath "$0")")"
found=
for i in "$root"/../*/build.ninja; do
c="$(dirname $i)"
[ -d "$c" ] || continue
[ "$(basename "$c")" != mkosi.builddir ] || continue
if [ -n "$found" ]; then
echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
exit 2
fi
found="$c"
done
if [ -z "$found" ]; then
echo 'Specify build directory with $BUILD_DIR' >&2
exit 1
fi
echo "$(realpath $found)"