22
33import glob
44import os
5+ import subprocess
56
67import pytest
7- from doitpy .pyflakes import Pyflakes
8- from doitpy .coverage import Config , Coverage , PythonPackage
9- from doitpy import docs
10- from doitpy .package import Package
8+ from pyflakes .api import checkPath
119
1210
1311DOIT_CONFIG = {
2321PY_FILES = CODE_FILES + TESTING_FILES
2422
2523
24+ def _check_pyflakes (py_file ):
25+ return not bool (checkPath (py_file ))
26+
2627def task_pyflakes ():
27- flaker = Pyflakes ()
28- yield flaker ('dodo.py' )
29- yield flaker .tasks ('doit/*.py' )
30- yield flaker .tasks ('tests/*.py' )
28+ for pattern in ['dodo.py' , 'doit/*.py' , 'tests/*.py' ]:
29+ for py_file in sorted (glob .glob (pattern )):
30+ yield {
31+ 'name' : py_file ,
32+ 'actions' : [(_check_pyflakes , [py_file ])],
33+ 'file_dep' : [py_file ],
34+ }
3135
3236def run_test (test ):
3337 return not bool (pytest .main ([test ]))
34- #return not bool(pytest.main("-v " + test))
3538def task_ut ():
3639 """run unit-tests"""
3740 for test in TEST_FILES :
@@ -41,14 +44,42 @@ def task_ut():
4144 'verbosity' : 0 }
4245
4346
47+ def _coverage_actions (modules , test = None ):
48+ """build coverage run/combine/report commands"""
49+ omit = ['tests/myecho.py' , 'tests/sample_process.py' ]
50+ actions = [
51+ 'coverage run --parallel-mode --concurrency multiprocessing'
52+ ' `which py.test`' + (' ' + test if test else '' ),
53+ 'coverage combine' ,
54+ 'coverage report --show-missing --omit {} {}' .format (
55+ ',' .join (omit ), ' ' .join (modules )),
56+ ]
57+ return actions
58+
4459def task_coverage ():
4560 """show coverage for all modules including tests"""
46- config = Config (branch = False , parallel = True , concurrency = 'multiprocessing' ,
47- omit = ['tests/myecho.py' , 'tests/sample_process.py' ])
48- cov = Coverage ([PythonPackage ('doit' , 'tests' )], config = config )
49- yield cov .all ()
50- yield cov .src ()
51- yield cov .by_module ()
61+ src = glob .glob ('doit/*.py' )
62+ tests = glob .glob ('tests/*.py' )
63+ all_modules = src + tests
64+
65+ yield {
66+ 'basename' : 'coverage' ,
67+ 'actions' : _coverage_actions (all_modules ),
68+ 'verbosity' : 2 ,
69+ }
70+ yield {
71+ 'basename' : 'coverage_src' ,
72+ 'actions' : _coverage_actions (src ),
73+ 'verbosity' : 2 ,
74+ }
75+ for test in glob .glob ('tests/test_*.py' ):
76+ source = 'doit/' + test [len ('tests/test_' ):]
77+ yield {
78+ 'basename' : 'coverage_module' ,
79+ 'name' : test ,
80+ 'actions' : _coverage_actions ([source , test ], test ),
81+ 'verbosity' : 2 ,
82+ }
5283
5384
5485
@@ -66,14 +97,38 @@ def task_rm_index():
6697 'file_dep' : ['doc/index.html' ],
6798 }
6899
100+ def _check_spelling (doc_file , dictionary ):
101+ """run spell checker, return False if misspelled words found"""
102+ cmd = 'hunspell -l -d en_US -p {} {}' .format (dictionary , doc_file )
103+ output = subprocess .check_output (cmd , shell = True ,
104+ universal_newlines = True )
105+ if output :
106+ print (output )
107+ return False
108+
69109def task_docs ():
70110 doc_files = glob .glob ('doc/*.rst' )
71111 doc_files += ['README.rst' , 'CONTRIBUTING.md' ,
72112 'doc/open_collective.md' ]
73- yield docs .spell (doc_files , 'doc/dictionary.txt' )
113+ dictionary = 'doc/dictionary.txt'
114+ for doc_file in doc_files :
115+ yield {
116+ 'basename' : 'spell' ,
117+ 'name' : doc_file ,
118+ 'actions' : [(_check_spelling , (doc_file , dictionary ))],
119+ 'file_dep' : [dictionary , doc_file ],
120+ 'verbosity' : 2 ,
121+ }
74122 sphinx_opts = "-A include_analytics=1 -A include_donate=1"
75- yield docs .sphinx (DOC_ROOT , DOC_BUILD_PATH , sphinx_opts = sphinx_opts ,
76- task_dep = ['spell' , 'rm_index' ])
123+ yield {
124+ 'basename' : 'sphinx' ,
125+ 'actions' : [
126+ 'sphinx-build -b html {} -d {}doctrees {} {}' .format (
127+ sphinx_opts , DOC_ROOT + '_build/' , DOC_ROOT , DOC_BUILD_PATH ),
128+ ],
129+ 'task_dep' : ['spell' , 'rm_index' ],
130+ 'verbosity' : 2 ,
131+ }
77132
78133def task_samples_check ():
79134 """check samples are at least runnuable without error"""
@@ -125,15 +180,6 @@ def task_website_update():
125180
126181
127182
128- def task_package ():
129- """create/upload package to pypi"""
130- pkg = Package ()
131- yield pkg .revision_git ()
132- yield pkg .manifest_git ()
133- yield pkg .sdist ()
134- # yield pkg.sdist_upload()
135-
136-
137183def task_codestyle ():
138184 return {
139185 'actions' : ['pycodestyle doit' ],
0 commit comments