From: Rob Browning Date: Fri, 13 Nov 2020 20:27:52 +0000 (-0600) Subject: Autodetect xdist and translate make -j to xdist -n X-Git-Tag: 0.32~21^2~7 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=63c1a8c02851b74309676588123d49710e1ecb29 Autodetect xdist and translate make -j to xdist -n Signed-off-by: Rob Browning --- diff --git a/HACKING b/HACKING index 31f48a5..9d2f4ff 100644 --- 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. diff --git a/Makefile b/Makefile index 266f7ea..e45719d 100644 --- 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 diff --git a/README.md b/README.md index cc2f2ef..c381558 100644 --- 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 ./HACKING 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