Skip to content

Commit ca16e49

Browse files
Added ability to auto run unit tests on all builds.
Signed-off-by: David Rebbe <drebbe@intrepidcs.com>
1 parent 03c179f commit ca16e49

10 files changed

Lines changed: 80 additions & 5 deletions

run_tests.bat

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@ECHO OFF
2+
REM run_tests.bat 2> test_log.txt
3+
mode con cols=140 lines=70
4+
5+
ECHO ================================================================== 1>&2
6+
ECHO PYTHON27 1>&2
7+
ECHO ================================================================== 1>&2
8+
C:\Python27\python setup.py test
9+
ECHO ================================================================== 1>&2
10+
ECHO PYTHON33 1>&2
11+
ECHO ================================================================== 1>&2
12+
C:\Python33\python setup.py test
13+
ECHO ================================================================== 1>&2
14+
ECHO PYTHON34 1>&2
15+
ECHO ================================================================== 1>&2
16+
C:\Python34\python setup.py test
17+
ECHO ================================================================== 1>&2
18+
ECHO PYTHON35 1>&2
19+
ECHO ================================================================== 1>&2
20+
C:\Python35\python setup.py test
21+
ECHO ================================================================== 1>&2
22+
ECHO PYTHON36 1>&2
23+
ECHO ================================================================== 1>&2
24+
C:\Python36-32\python setup.py test
25+
26+
ECHO ================================================================== 1>&2
27+
ECHO PYTHON27-64 1>&2
28+
ECHO ================================================================== 1>&2
29+
C:\Python27-64\python setup.py test
30+
ECHO ================================================================== 1>&2
31+
ECHO PYTHON34-64 1>&2
32+
ECHO ================================================================== 1>&2
33+
C:\Python34-64\python setup.py test
34+
ECHO ================================================================== 1>&2
35+
ECHO PYTHON35-64 1>&2
36+
ECHO ================================================================== 1>&2
37+
C:\Python35-64\python setup.py test
38+
39+
pause

setup.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
11
#!/usr/bin/env python3
22
from setuptools import setup, Extension
3+
34
from distutils.command import build as build_module
45
import os
56
import platform
7+
import sys
8+
import unittest
69

710
MAJOR_VERSION = 2
811
MINOR_VERSION = 11
912

13+
def _run_tests():
14+
directory = os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__))
15+
loader = unittest.defaultTestLoader
16+
runner = unittest.TextTestRunner()
17+
suite = loader.discover(os.path.join(directory, 'test'))
18+
runner.run(suite)
19+
20+
try:
21+
from setuptools.command.test import test
22+
23+
24+
class UnitTests(test):
25+
def finalize_options(self):
26+
test.finalize_options(self)
27+
self.test_args = []
28+
self.test_suite = True
29+
30+
def run_tests(self):
31+
_run_tests()
32+
except ImportError:
33+
from distutils.core import Command
34+
35+
class UnitTests(Command):
36+
user_options = []
37+
def initialize_options(self):
38+
pass
39+
40+
def finalize_options(self):
41+
pass
42+
43+
def run(self):
44+
_run_tests()
45+
46+
1047
class build(build_module.build):
1148
def run(self):
1249
import extract_icsneo40_defines # there should be a better way to do this...
@@ -54,7 +91,7 @@ def run(self):
5491
maintainer = 'David Rebbe',
5592
maintainer_email='drebbe@intrepidcs.com',
5693
url='https://github.com/intrepidcs/python_ics/',
57-
cmdclass = { 'build': build, },
94+
cmdclass = { 'build': build, 'test': UnitTests, },
5895
download_url = 'https://github.com/intrepidcs/python_ics/releases',
5996
ext_modules = [module],
6097
classifiers = [
File renamed without changes.
File renamed without changes.

test/test_find_devices.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class TestFindDevicesLegacy(unittest.TestCase):
99
@classmethod
1010
def setUpClass(self):
11-
ics.override_library_name(r"C:\Windows\SysWOW64\icsneo40-legacy.dll")
11+
ics.override_library_name(r"icsneo40-legacy.dll")
1212
if _DEBUG:
1313
import os
1414
input("Pause... " + str(os.getpid()))
@@ -36,7 +36,7 @@ def test_find_fire2_and_vcan3(self):
3636
class TestFindDevicesNewStyle(unittest.TestCase):
3737
@classmethod
3838
def setUpClass(self):
39-
ics.override_library_name(r"C:\Windows\SysWOW64\icsneo40.dll")
39+
ics.override_library_name(r"icsneo40.dll")
4040
if _DEBUG:
4141
import os
4242
input("Pause... " + str(os.getpid()))
@@ -65,8 +65,7 @@ def test_find_fire2_and_vcan3(self):
6565
class TestFindDevicesNewStyleWithLegacyDLL(unittest.TestCase):
6666
@classmethod
6767
def setUpClass(self):
68-
import ics
69-
ics.override_library_name(r"C:\Windows\SysWOW64\icsneo40-legacy.dll")
68+
ics.override_library_name(r"icsneo40-legacy.dll")
7069
if _DEBUG:
7170
import os
7271
input("Pause... " + str(os.getpid()))

0 commit comments

Comments
 (0)