Skip to content

Commit

Permalink
add static unit tests; move test entrypoint; run black
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 committed Nov 21, 2018
1 parent 332c770 commit 7efcac7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
ignore = E501, E203 # line length, whitespace before ':'
7 changes: 4 additions & 3 deletions gdbgui/statemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ def connect_client(self, client_id, desired_gdbpid):
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:
Expand Down
3 changes: 1 addition & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 1 addition & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))

Expand All @@ -25,25 +24,6 @@
.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,
Expand Down Expand Up @@ -81,7 +61,6 @@ def run(self):
},
extras_require={},
zip_safe=False,
cmdclass={"test": TestCommand},
install_requires=REQUIRED,
classifiers=[
"Intended Audience :: Developers",
Expand Down
3 changes: 3 additions & 0 deletions tests/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import test_app, static_tests

exit(test_app.main() + static_tests.main()
18 changes: 18 additions & 0 deletions tests/static_tests.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 7efcac7

Please sign in to comment.