Use py.test

This commit is contained in:
Bastian Kleineidam 2012-11-14 20:24:34 +01:00
parent 21ae776aca
commit d8407a73ce
1 changed files with 10 additions and 26 deletions

View File

@ -9,40 +9,33 @@ ARCHIVE_WIN32:=$(APPNAME)-$(VERSION).exe
PY_FILES_DIRS := patool setup.py patoolib tests PY_FILES_DIRS := patool setup.py patoolib tests
PY2APPOPTS ?= PY2APPOPTS ?=
ifeq ($(shell uname),Darwin) ifeq ($(shell uname),Darwin)
NOSETESTS:=/usr/local/share/python/nosetests
NUMPROCESSORS:=$(shell sysctl -a | grep machdep.cpu.core_count | cut -d " " -f 2) NUMPROCESSORS:=$(shell sysctl -a | grep machdep.cpu.core_count | cut -d " " -f 2)
CHMODMINUSMINUS:= CHMODMINUSMINUS:=
else else
NOSETESTS:=$(shell which nosetests)
NUMPROCESSORS:=$(shell grep -c processor /proc/cpuinfo) NUMPROCESSORS:=$(shell grep -c processor /proc/cpuinfo)
CHMODMINUSMINUS:=-- CHMODMINUSMINUS:=--
endif endif
+NOSETESTS:=$(shell which nosetests) # Pytest options:
# Nose options:
# - do not show output of successful tests
# - use multiple processors # - use multiple processors
# - be verbose # - write test results in file
# - only run test_* methods # - run all tests found in the "tests" subdirectory
NOSEOPTS:=--logging-clear-handlers --processes=$(NUMPROCESSORS) -v -m '^test_.*' PYTESTOPTS:=-n $(NUMPROCESSORS) --resultlog=testresults.txt
# which test modules to run # which test modules to run
TESTS ?= tests/ TESTS ?= tests/
# set test options, eg. to "--nologcapture" # set test options
TESTOPTS= TESTOPTS=
all: all:
.PHONY: chmod
chmod: chmod:
-chmod -R a+rX,u+w,go-w $(CHMODMINUSMINUS) * -chmod -R a+rX,u+w,go-w $(CHMODMINUSMINUS) *
find . -type d -exec chmod 755 {} \; find . -type d -exec chmod 755 {} \;
.PHONY: dist
dist: dist:
git archive --format=tar --prefix=$(APPNAME)-$(VERSION)/ HEAD | gzip -9 > ../$(ARCHIVE) git archive --format=tar --prefix=$(APPNAME)-$(VERSION)/ HEAD | gzip -9 > ../$(ARCHIVE)
# cd .. && zip -r - patool-git -x "**/.git/**" > $(HOME)/temp/share/patool-devel.zip # cd .. && zip -r - patool-git -x "**/.git/**" > $(HOME)/temp/share/patool-devel.zip
.PHONY: sign
sign: sign:
[ -f ../$(ARCHIVE).sha1 ] || sha1sum ../$(ARCHIVE) > ../$(ARCHIVE).sha1 [ -f ../$(ARCHIVE).sha1 ] || sha1sum ../$(ARCHIVE) > ../$(ARCHIVE).sha1
[ -f ../$(ARCHIVE).asc ] || gpg --detach-sign --armor ../$(ARCHIVE) [ -f ../$(ARCHIVE).asc ] || gpg --detach-sign --armor ../$(ARCHIVE)
@ -51,7 +44,6 @@ sign:
[ -f dist/$(ARCHIVE_RPM).sha1 ] || sha1sum dist/$(ARCHIVE_RPM) > dist/$(ARCHIVE_RPM).sha1 [ -f dist/$(ARCHIVE_RPM).sha1 ] || sha1sum dist/$(ARCHIVE_RPM) > dist/$(ARCHIVE_RPM).sha1
[ -f dist/$(ARCHIVE_RPM).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_RPM) [ -f dist/$(ARCHIVE_RPM).asc ] || gpg --detach-sign --armor dist/$(ARCHIVE_RPM)
.PHONY: upload
upload: doc/README.md sign upload: doc/README.md sign
rsync -avP -e ssh doc/README.md ../$(ARCHIVE)* ../$(ARCHIVE_WIN32)* dist/$(ARCHIVE_RPM)* calvin,patool@frs.sourceforge.net:/home/frs/project/p/pa/patool/$(VERSION)/ rsync -avP -e ssh doc/README.md ../$(ARCHIVE)* ../$(ARCHIVE_WIN32)* dist/$(ARCHIVE_RPM)* calvin,patool@frs.sourceforge.net:/home/frs/project/p/pa/patool/$(VERSION)/
@ -62,7 +54,6 @@ doc/README.md: doc/README-Download.md.tmpl doc/changelog.txt
awk '/released/ {c++}; c==2 {exit}; {print " " $$0}' doc/changelog.txt >> $@ awk '/released/ {c++}; c==2 {exit}; {print " " $$0}' doc/changelog.txt >> $@
.PHONY: release
release: clean releasecheck dist upload release: clean releasecheck dist upload
git tag upstream/$(VERSION) git tag upstream/$(VERSION)
@echo "Register at Python Package Index..." @echo "Register at Python Package Index..."
@ -70,7 +61,6 @@ release: clean releasecheck dist upload
freecode-submit < patool.freecode freecode-submit < patool.freecode
.PHONY: releasecheck
releasecheck: check test releasecheck: check test
@if egrep -i "xx\.|xxxx|\.xx" doc/changelog.txt > /dev/null; then \ @if egrep -i "xx\.|xxxx|\.xx" doc/changelog.txt > /dev/null; then \
echo "Could not release: edit doc/changelog.txt release date"; false; \ echo "Could not release: edit doc/changelog.txt release date"; false; \
@ -84,17 +74,14 @@ releasecheck: check test
fi fi
# Build OSX installer # Build OSX installer
.PHONY: app
app: clean chmod app: clean chmod
$(PYTHON) setup.py py2app $(PY2APPOPTS) $(PYTHON) setup.py py2app $(PY2APPOPTS)
.PHONY: rpm
rpm: rpm:
$(PYTHON) setup.py bdist_rpm $(PYTHON) setup.py bdist_rpm
# The check programs used here are mostly local scripts on my private system. # The check programs used here are mostly local scripts on my private system.
# So for other developers there is no need to execute this target. # So for other developers there is no need to execute this target.
.PHONY: check
check: check:
[ ! -d .svn ] || check-nosvneolstyle -v [ ! -d .svn ] || check-nosvneolstyle -v
check-copyright check-copyright
@ -102,34 +89,31 @@ check:
py-tabdaddy py-tabdaddy
py-unittest2-compat tests/ py-unittest2-compat tests/
.PHONY: pyflakes
pyflakes: pyflakes:
pyflakes $(PY_FILES_DIRS) pyflakes $(PY_FILES_DIRS)
.PHONY: count
count: count:
@sloccount patool patoolib | grep "Total Physical Source Lines of Code" @sloccount patool patoolib | grep "Total Physical Source Lines of Code"
.PHONY: clean
clean: clean:
find . -name \*.pyc -delete find . -name \*.pyc -delete
find . -name \*.pyo -delete find . -name \*.pyo -delete
rm -rf build dist rm -rf build dist
.PHONY: test
test: test:
$(PYTHON) $(NOSETESTS) $(NOSEOPTS) $(TESTOPTS) $(TESTS) $(PYTHON) -m pytest $(PYTESTOPTS) $(TESTOPTS) $(TESTS)
doc/patool.txt: doc/patool.1 doc/patool.txt: doc/patool.1
cols=`stty size | cut -d" " -f2`; stty cols 72; man -l doc/patool.1 | perl -pe 's/.\cH//g' > doc/patool.txt; stty cols $$cols cols=`stty size | cut -d" " -f2`; stty cols 72; man -l doc/patool.1 | perl -pe 's/.\cH//g' > doc/patool.txt; stty cols $$cols
.PHONY: deb
deb: deb:
git-buildpackage --git-export-dir=../build-area/ --git-upstream-branch=master --git-debian-branch=debian --git-ignore-new git-buildpackage --git-export-dir=../debian/build-area/ --git-upstream-branch=master --git-debian-branch=debian --git-ignore-new
update-copyright: update-copyright:
update-copyright --holder="Bastian Kleineidam" update-copyright --holder="Bastian Kleineidam"
.PHONY: changelog
changelog: changelog:
sftrack_changelog patool calvin@users.sourceforge.net doc/changelog.txt $(DRYRUN) sftrack_changelog patool calvin@users.sourceforge.net doc/changelog.txt $(DRYRUN)
.PHONY: changelog update-copyright deb test clean count pyflakes check rpm app
.PHONY: releasecheck release upload sign dist chmod all