Run Python unittests and doctests.
Add a meta/check.sh script that runs unit tests before the syntax linters. Add unittest converters for the existing doctests.
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
# Run unit tests.
|
||||||
|
python -m unittest discover
|
||||||
|
|
||||||
# Check Python sources for Python 3 compatibility using pylint.
|
# Check Python sources for Python 3 compatibility using pylint.
|
||||||
#
|
#
|
||||||
# Install pylint with 'pip install pylint'.
|
# Install pylint with 'pip install pylint'.
|
||||||
cd $(dirname "$0")
|
|
||||||
pylint --py3k --reports=no -- *.py cretonne isa
|
pylint --py3k --reports=no -- *.py cretonne isa
|
||||||
flake8 .
|
flake8 .
|
||||||
@@ -74,7 +74,3 @@ def compute_quadratic(items, hash_function):
|
|||||||
table[h] = i
|
table[h] = i
|
||||||
|
|
||||||
return table
|
return table
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
import doctest
|
|
||||||
doctest.testmod()
|
|
||||||
|
|||||||
@@ -121,7 +121,3 @@ class Formatter(object):
|
|||||||
"""Add a (multi-line) documentation comment."""
|
"""Add a (multi-line) documentation comment."""
|
||||||
s = re.sub('^', self.indent + '/// ', s, flags=re.M) + '\n'
|
s = re.sub('^', self.indent + '/// ', s, flags=re.M) + '\n'
|
||||||
self.lines.append(s)
|
self.lines.append(s)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
import doctest
|
|
||||||
doctest.testmod()
|
|
||||||
|
|||||||
8
meta/test_constant_hash.py
Normal file
8
meta/test_constant_hash.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
import doctest
|
||||||
|
import constant_hash
|
||||||
|
|
||||||
|
|
||||||
|
def load_tests(loader, tests, ignore):
|
||||||
|
tests.addTests(doctest.DocTestSuite(constant_hash))
|
||||||
|
return tests
|
||||||
8
meta/test_srcgen.py
Normal file
8
meta/test_srcgen.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from __future__ import absolute_import
|
||||||
|
import doctest
|
||||||
|
import srcgen
|
||||||
|
|
||||||
|
|
||||||
|
def load_tests(loader, tests, ignore):
|
||||||
|
tests.addTests(doctest.DocTestSuite(srcgen))
|
||||||
|
return tests
|
||||||
Reference in New Issue
Block a user