Skip to content

Commit ded6577

Browse files
committed
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 systemd#7494.
1 parent 4fb55f1 commit ded6577

File tree

8 files changed

+40
-25
lines changed

8 files changed

+40
-25
lines changed

test/Makefile.guess

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/TEST-01-BASIC/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include ../Makefile.guess
1+
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
22

33
all setup clean run:
44
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

test/TEST-13-NSPAWN-SMOKE/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include ../Makefile.guess
1+
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
22

33
all setup run:
44
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

test/TEST-17-UDEV-WANTS/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include ../Makefile.guess
1+
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
22

33
all setup clean run:
44
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include ../Makefile.guess
1+
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
22

33
all setup clean run:
44
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

test/TEST-19-DELEGATE/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include ../Makefile.guess
1+
BUILD_DIR=$(exec ../../tools/find-build-dir.sh)
22

33
all setup clean run:
44
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@

test/run-integration-tests.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
#!/bin/bash -e
22

3-
if ! test -d ../build ; then
4-
echo "Expected build directory in ../build, but couldn't find it." >&2
5-
exit 1
6-
fi
3+
BUILD_DIR="$($(dirname "$0")/../tools/find-build-dir.sh)"
74

8-
ninja -C ../build
5+
ninja -C "$BUILD_DIR"
96

107
declare -A results
118

129
RESULT=0
1310
FAILURES=0
1411

12+
cd "$(dirname "$0")"
1513
for TEST in TEST-??-* ; do
1614
echo -e "\n--x-- Starting $TEST --x--"
1715
set +e
18-
make -C "$TEST" BUILD_DIR=$(pwd)/../build clean setup run
16+
make -C "$TEST" "BUILD_DIR=$BUILD_DIR" clean setup run
1917
RESULT=$?
2018
set -e
2119
echo "--x-- Result of $TEST: $RESULT --x--"

tools/find-build-dir.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh -e
2+
3+
# Try to guess the build directory:
4+
# we look for subdirectories of the parent directory that look like ninja build dirs.
5+
6+
if [ -n "$BUILD_DIR" ]; then
7+
echo "$(realpath "$BUILD_DIR")"
8+
exit 0
9+
fi
10+
11+
root="$(dirname "$(realpath "$0")")"
12+
13+
found=
14+
for i in "$root"/../*/build.ninja; do
15+
c="$(dirname $i)"
16+
[ -d "$c" ] || continue
17+
[ "$(basename "$c")" != mkosi.builddir ] || continue
18+
19+
if [ -n "$found" ]; then
20+
echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
21+
exit 2
22+
fi
23+
found="$c"
24+
done
25+
26+
if [ -z "$found" ]; then
27+
echo 'Specify build directory with $BUILD_DIR' >&2
28+
exit 1
29+
fi
30+
31+
echo "$(realpath $found)"

0 commit comments

Comments
 (0)