add static unit tests; move test entrypoint; run black

This commit is contained in:
Chad Smith 2018-10-30 18:46:33 -07:00
parent 2bc66225de
commit f6bad41f05
6 changed files with 30 additions and 27 deletions

3
.flake8 Normal file
View file

@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
ignore = E501, E203 # line length, whitespace before ':'

View file

@ -29,9 +29,10 @@ class StateManager(object):
if controller:
self.controller_to_client_ids[controller].append(client_id)
message = "gdbgui is using existing subprocess with pid %s, "
"originally opened with command %s" % (str(
desired_gdbpid
), controller.get_subprocess_cmd())
"originally opened with command %s" % (
str(desired_gdbpid),
controller.get_subprocess_cmd(),
)
using_existing = True
pid = desired_gdbpid
else:

View file

@ -1,8 +1,7 @@
# run pip install -r dev_requirements.txt before running make test
.PHONY: test publish executable
test:
# flake8 gdbgui/backend.py --ignore=E121,E123,E126,E128,E501
python setup.py test
python -m test
yarn test
yarn build
python setup.py checkdocs

View file

@ -3,8 +3,7 @@
import io
import os
import sys
from setuptools import find_packages, setup, Command
from setuptools import find_packages, setup
CURDIR = os.path.abspath(os.path.dirname(__file__))
@ -25,25 +24,6 @@ VERSION = (
.strip()
)
class TestCommand(Command):
description = "test task"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
# import here so dependency error on Flask is not
# raised
from tests import test_app
sys.exit(test_app.main())
setup(
name="gdbgui",
version=VERSION,
@ -81,7 +61,6 @@ setup(
},
extras_require={},
zip_safe=False,
cmdclass={"test": TestCommand},
install_requires=REQUIRED,
classifiers=[
"Intended Audience :: Developers",

3
tests/__main__.py Normal file
View file

@ -0,0 +1,3 @@
from . import test_app, static_tests
exit(test_app.main() + static_tests.main()

18
tests/static_tests.py Normal file
View file

@ -0,0 +1,18 @@
import subprocess
def run(cmd):
print(f"Running {' '.join(cmd)!r}")
return subprocess.run(cmd).returncode
def main():
files = ["gdbgui", "tests", "setup.py"]
ret = 0
ret += run(["black", "--check"] + files)
ret += run(["flake8"] + files)
return ret
if __name__ == "__main__":
exit(main())