
6 changed files with 162 additions and 59 deletions
@ -0,0 +1 @@ |
|||
./.coverage |
@ -0,0 +1,55 @@ |
|||
#! /usr/bin/make -f
|
|||
|
|||
# Makefile
|
|||
# Part of reportbug, a Debian bug reporting tool.
|
|||
#
|
|||
# Copyright © 2008 Ben Finney <ben+debian@benfinney.id.au>
|
|||
# This is free software; you may copy, modify and/or distribute this work
|
|||
# under the terms of the GNU General Public License, version 2 or later.
|
|||
# No warranty expressed or implied. See the file LICENSE for details.
|
|||
|
|||
# Makefile for reportbug project
|
|||
|
|||
SHELL = /bin/bash |
|||
PATH = /usr/bin:/bin |
|||
|
|||
# Directories with semantic meaning
|
|||
CODE_PACKAGE_DIR := . |
|||
CODE_PROGRAM_DIR := . |
|||
TEST_DIR := test |
|||
|
|||
# Variables that will be extended by module include files
|
|||
GENERATED_FILES := |
|||
CODE_MODULES := |
|||
CODE_PROGRAMS := |
|||
|
|||
# List of modules (directories) that comprise our 'make' project
|
|||
MODULES += ${CODE_PACKAGE_DIR} |
|||
MODULES += ${TEST_DIR} |
|||
|
|||
RM = rm |
|||
|
|||
# Include the make data for each module
|
|||
include $(patsubst %,%/module.mk,${MODULES}) |
|||
|
|||
|
|||
.PHONY: all |
|||
all: build |
|||
|
|||
.PHONY: build |
|||
build: |
|||
|
|||
.PHONY: install |
|||
install: build |
|||
|
|||
|
|||
.PHONY: clean |
|||
clean: |
|||
$(RM) -rf ${GENERATED_FILES} |
|||
|
|||
|
|||
.PHONY: test |
|||
test: |
|||
|
|||
.PHONY: qa |
|||
qa: |
@ -0,0 +1,26 @@ |
|||
# :vim: filetype=make : -*- makefile; coding: utf-8; -*-
|
|||
|
|||
# module.mk
|
|||
# Part of reportbug, a Debian bug reporting tool.
|
|||
#
|
|||
# Copyright © 2008 Ben Finney <ben+debian@benfinney.id.au>
|
|||
# This is free software; you may copy, modify and/or distribute this work
|
|||
# under the terms of the GNU General Public License, version 2 or later.
|
|||
# No warranty expressed or implied. See the file LICENSE for details.
|
|||
|
|||
# Makefile module for reportbug Python package
|
|||
|
|||
MODULE_DIR := . |
|||
|
|||
CODE_MODULES += $(shell find ${CODE_PACKAGE_DIR} -name '*.py') |
|||
|
|||
CODE_PROGRAM_NAMES += reportbug |
|||
CODE_PROGRAM_NAMES += querybts |
|||
CODE_PROGRAM_NAMES += handle_bugscript |
|||
CODE_PROGRAM_NAMES += script |
|||
|
|||
CODE_PROGRAMS += $(addprefix ${CODE_PROGRAM_DIR}/,${CODE_PROGRAM_NAMES}) |
|||
|
|||
GENERATED_FILES += $(shell find ${MODULE_DIR} -name '*.pyc') |
|||
|
|||
PYTHON = python |
@ -0,0 +1,80 @@ |
|||
# :vim: filetype=make : -*- makefile; coding: utf-8; -*-
|
|||
|
|||
# test/module.mk
|
|||
# Part of reportbug, a Debian bug reporting tool.
|
|||
#
|
|||
# Copyright © 2008 Ben Finney <ben+debian@benfinney.id.au>
|
|||
# This is free software; you may copy, modify and/or distribute this work
|
|||
# under the terms of the GNU General Public License, version 2 or later.
|
|||
# No warranty expressed or implied. See the file LICENSE for details.
|
|||
|
|||
# Makefile module for test suite
|
|||
|
|||
MODULE_DIR := ${TEST_DIR} |
|||
|
|||
NOSETESTS = nosetests |
|||
NOSETESTS_OPTS = --exclude='^(?!test_)' |
|||
PYFLAKES = pyflakes |
|||
PYLINT = pylint |
|||
COVERAGE = python-coverage |
|||
DATE = date |
|||
DATE_FORMAT = '%Y-%m-%d %H:%M:%S' |
|||
INWAIT = inotifywait |
|||
INWAIT_OPTS = -q -r -e modify -e create -t 0 |
|||
TEST_INWAIT_FILES = ${CODE_PACKAGE_DIR} ${CODE_PROGRAMS} ${TEST_DIR} |
|||
|
|||
NOSETESTS_FILES = ${TEST_DIR} |
|||
nosetests_cmd = $(NOSETESTS) ${NOSETESTS_OPTS} ${NOSETESTS_FILES} |
|||
|
|||
coverage_files += ${CODE_MODULES} |
|||
# Not until python-coverage is updated with upstream fixes (2008-05-04)
|
|||
#coverage_files += ${CODE_PROGRAMS}
|
|||
|
|||
GENERATED_FILES += .coverage |
|||
|
|||
|
|||
# usage: $(call test-output-banner,message)
|
|||
define test-output-banner |
|||
@ echo -n ${1} ; \
|
|||
$(DATE) +${DATE_FORMAT} |
|||
endef |
|||
|
|||
|
|||
.PHONY: nosetests |
|||
nosetests: |
|||
$(call test-output-banner, "Test run: " ) |
|||
$(nosetests_cmd) |
|||
|
|||
test: nosetests |
|||
|
|||
# usage: $(call test-wait)
|
|||
define test-wait |
|||
$(INWAIT) ${INWAIT_OPTS} ${TEST_INWAIT_FILES} |
|||
endef |
|||
|
|||
.PHONY: test-continuous |
|||
test-continuous: |
|||
while true ; do \
|
|||
clear ; \
|
|||
$(MAKE) test ; \
|
|||
$(call test-wait) ; \
|
|||
done |
|||
|
|||
|
|||
.PHONY: pyflakes |
|||
pyflakes: |
|||
$(PYFLAKES) . |
|||
|
|||
.PHONY: pylint |
|||
pylint: |
|||
$(PYLINT) ${CODE_PACKAGE_DIR} |
|||
$(PYLINT) ${CODE_PROGRAMS} |
|||
$(PYLINT) ${TEST_DIR} |
|||
|
|||
.PHONY: coverage |
|||
coverage: NOSETEST_OPTS += --with-coverage |
|||
coverage: |
|||
$(nosetests_cmd) |
|||
$(COVERAGE) -r -m ${coverage_files} |
|||
|
|||
qa: pyflakes coverage |
@ -1,59 +0,0 @@ |
|||
# -*- coding: utf-8; -*- |
|||
|
|||
# test/suite.py |
|||
# Part of reportbug, a Debian bug reporting tool. |
|||
# |
|||
# Copyright © 2008 Ben Finney <ben+python@benfinney.id.au> |
|||
# This is free software; you may copy, modify and/or distribute this work |
|||
# under the terms of the GNU General Public License, version 2 or later. |
|||
# No warranty expressed or implied. See the file COPYING for details. |
|||
|
|||
""" Unit test suite for reportbug |
|||
""" |
|||
|
|||
import unittest |
|||
import sys |
|||
import os |
|||
|
|||
|
|||
def get_python_modules(file_list, file_suffix = '.py'): |
|||
""" Return a list of module names from a filename list """ |
|||
python_modules = [m[:m.rfind(file_suffix)] for m in file_list |
|||
if m.endswith(file_suffix)] |
|||
return python_modules |
|||
|
|||
def get_test_modules(module_list, module_prefix = 'test_'): |
|||
""" Return the list of modules that are named as test modules """ |
|||
test_modules = [m for m in module_list |
|||
if m.startswith(module_prefix)] |
|||
return test_modules |
|||
|
|||
|
|||
def suite(): |
|||
""" Create the test suite for this module """ |
|||
loader = unittest.TestLoader() |
|||
test_dir = os.path.dirname(__file__) |
|||
python_modules = get_python_modules(os.listdir(test_dir)) |
|||
module_list = get_test_modules(python_modules) |
|||
suite = loader.loadTestsFromNames(module_list) |
|||
|
|||
return suite |
|||
|
|||
|
|||
def __main__(argv=None): |
|||
""" Mainline function for this module """ |
|||
from sys import argv as sys_argv |
|||
if not argv: |
|||
argv = sys_argv |
|||
|
|||
exitcode = None |
|||
try: |
|||
unittest.main(argv=argv, defaultTest='suite') |
|||
except SystemExit, e: |
|||
exitcode = e.code |
|||
|
|||
return exitcode |
|||
|
|||
if __name__ == '__main__': |
|||
exitcode = __main__(sys.argv) |
|||
sys.exit(exitcode) |
Loading…
Reference in new issue