test: try to guess the build directory
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 5 Jul 2017 03:00:43 +0000 (23:00 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 18 Jul 2017 14:05:06 +0000 (10:05 -0400)
This will work if $(TOP_SRC_DIR) has exactly one subdirectory with
.ninja_deps. Otherwise, BUILD_DIR has to be specified.

test/Makefile.guess [new file with mode: 0644]
test/TEST-01-BASIC/Makefile
test/TEST-13-NSPAWN-SMOKE/Makefile

diff --git a/test/Makefile.guess b/test/Makefile.guess
new file mode 100644 (file)
index 0000000..1916d09
--- /dev/null
@@ -0,0 +1,14 @@
+# 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
index c29fd06..b895de8 100644 (file)
@@ -1,2 +1,4 @@
+include ../Makefile.guess
+
 all setup clean run:
-       @basedir=../.. TEST_BASE_DIR=../ ./test.sh --$@
+       @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
index e58c0d9..41cca23 100644 (file)
@@ -1,5 +1,7 @@
+include ../Makefile.guess
+
 all setup run:
-       @basedir=../.. TEST_BASE_DIR=../ ./test.sh --$@
+       @basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
 clean:
        @basedir=../.. TEST_BASE_DIR=../ ./test.sh --clean
        @rm -f has-overflow