]> arthur.barton.de Git - bup.git/commitdiff
Autodetect xdist and translate make -j to xdist -n
authorRob Browning <rlb@defaultvalue.org>
Fri, 13 Nov 2020 20:27:52 +0000 (14:27 -0600)
committerRob Browning <rlb@defaultvalue.org>
Thu, 26 Nov 2020 21:53:09 +0000 (15:53 -0600)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
HACKING
Makefile
README.md

diff --git a/HACKING b/HACKING
index 31f48a556336b133af5cfc46fa2ed0526ec97336..9d2f4ff506e5716993edd41b248935bbc9147283 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -69,6 +69,11 @@ For example:
     ./pytest test/int/test_git.py
     ./pytest test/ext/test-ftp
 
+If you have the xdist module installed, then you can specify its `-n`
+option to run the tests in parallel (e.g. `./pytest -nauto ...`), or
+you can specify `-j` to make, which will be translated to xdist with
+`-j` becoming `-nauto` and `-jN` becoming `-nN`.
+
 Internal tests that test bup's code directly are located in test/int,
 and external tests that test bup from the outside, typically by
 running the executable, are located in test/ext.
index 266f7ea08d8d18c2dad14c48c0acf2b56453e4b7..e45719d6118027d5d841c31370920dfdd07ea710 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -159,8 +159,18 @@ lib/bup/_helpers$(SOEXT): \
 test/tmp:
        mkdir test/tmp
 
+ifeq (yes,$(shell config/bin/python -c "import xdist; print('yes')" 2>/dev/null))
+  # MAKEFLAGS must not be in an immediate := assignment
+  parallel_opt = $(lastword $(filter -j%,$(MAKEFLAGS)))
+  get_parallel_n = $(patsubst -j%,%,$(parallel_opt))
+  maybe_specific_n = $(if $(filter -j%,$(parallel_opt)),-n$(get_parallel_n))
+  xdist_opt = $(if $(filter -j,$(parallel_opt)),-nauto,$(maybe_specific_n))
+else
+  xdist_opt =
+endif
+
 test: all test/tmp
-       ./pytest
+       ./pytest $(xdist_opt)
 
 stupid:
        PATH=/bin:/usr/bin $(MAKE) test
@@ -168,7 +178,7 @@ stupid:
 check: test
 
 distcheck: all
-       ./pytest -m release
+       ./pytest $(xdist_opt) -m release
 
 long-test: export BUP_TEST_LEVEL=11
 long-test: test
index cc2f2ef962a343a857992d7f495fcc6e5f18586a..c3815582482fb77d7a546ce1fa527b38bd008b35 100644 (file)
--- a/README.md
+++ b/README.md
@@ -152,6 +152,7 @@ From source
     apt-get install python-pyxattr
     apt-get install pkg-config linux-libc-dev libacl1-dev
     apt-get install acl attr
+    apt-get isntall python-pytest-xdist # optional (parallel tests)
     apt-get install libreadline-dev # optional (bup ftp)
     apt-get install python-tornado # optional (bup web)
     ```
@@ -198,6 +199,14 @@ From source
     make check
     ```
        
+    If you have the Python xdist module installed, then you can
+    probably run the tests faster by adding the make -j option (see <a
+    href="HACKING">./HACKING</a> for additional information):
+
+    ```sh
+    make -j check
+    ```
+
     The tests should pass.  If they don't pass for you, stop here and
     send an email to bup-list@googlegroups.com.  Though if there are
     symbolic links along the current working directory path, the tests