Patchwork [1,of,2] Makefile: introduce testpy-% target for testing with a specifc Python

login
register
mail settings
Submitter Augie Fackler
Date March 3, 2015, 7:36 p.m.
Message ID <a94467d7f4422eaf79ce.1425411363@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7885/
State Accepted
Headers show

Comments

Augie Fackler - March 3, 2015, 7:36 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1423070776 18000
#      Wed Feb 04 12:26:16 2015 -0500
# Node ID a94467d7f4422eaf79cea5671d57eb3ec8fecaf4
# Parent  67952dc7a88faf32211e61b8f9606f62d271eaf3
Makefile: introduce testpy-% target for testing with a specifc Python

This makes it easy to do 'make testpy-2.4.6 TESTFLAGS="-j 16"' and the
Makefile will build Python if needed and then run tests (with -j 16)
with the resulting Python.

You can set the environment variable HGPYTHONS to a nice location on
your machine to cache the Python builds globally. If that's not set,
it builds them inside build/pythons.

Patch

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,8 @@ 
 PREFIX=/usr/local
 export PREFIX
 PYTHON=python
+$(eval HGROOT := $(shell pwd))
+HGPYTHONS ?= $(HGROOT)/build/pythons
 PURE=
 PYFILES:=$(shell find mercurial hgext doc -name '*.py')
 DOCFILES=mercurial/help/*.txt
@@ -98,6 +100,13 @@  tests:
 test-%:
 	cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
 
+testpy-%:
+	@echo Looking for Python $* in $(HGPYTHONS)
+	[ -e $(HGPYTHONS)/$*/bin/python ] || ( \
+	cd $$(mktemp --directory --tmpdir) && \
+        $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
+	cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
+
 check-code:
 	hg manifest | xargs python contrib/check-code.py