summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2019-04-21 15:57:25 +0200
committerMarcus Müller <mmueller@gnuradio.org>2019-04-21 17:48:55 +0200
commitcbe60a36717f5d26b5eee6cc87ae4394cebbf427 (patch)
treeebb4ddf2adce848e2ffd1a3ae256ad66d2cc61b2
parenta117a7fc5c4bb4d581489132731647fffcf8b960 (diff)
modtool tests: Don't install tests, but make them work in build dir
This includes explicitly stating the template directory in the test, and changing the CMakeLists to not install but test.
-rw-r--r--gr-utils/python/modtool/tests/CMakeLists.txt28
-rw-r--r--gr-utils/python/modtool/tests/test_modtool.py24
2 files changed, 39 insertions, 13 deletions
diff --git a/gr-utils/python/modtool/tests/CMakeLists.txt b/gr-utils/python/modtool/tests/CMakeLists.txt
index beb77cba15..076b98a182 100644
--- a/gr-utils/python/modtool/tests/CMakeLists.txt
+++ b/gr-utils/python/modtool/tests/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2018 Free Software Foundation, Inc.
+# Copyright 2019 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -19,9 +19,25 @@
include(GrPython)
-GR_PYTHON_INSTALL(FILES
- __init__.py
- test_modtool.py
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/modtool/tests
-)
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+ set(GR_TEST_TARGET_DEPS "")
+ set(GR_TEST_LIBRARY_DIRS "")
+ set(GR_TEST_PYTHON_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../..
+ ${CMAKE_BINARY_DIR}/gnuradio-runtime/python
+ ${CMAKE_BINARY_DIR}/gnuradio-runtime/swig
+ )
+
+ include(GrTest)
+ file(GLOB py_qa_test_files "test_*.py")
+
+ foreach(py_qa_test_file ${py_qa_test_files})
+ get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
+ GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
+ endforeach(py_qa_test_file)
+
+endif(ENABLE_TESTING)
diff --git a/gr-utils/python/modtool/tests/test_modtool.py b/gr-utils/python/modtool/tests/test_modtool.py
index 56795ecb9c..3cfd735f90 100644
--- a/gr-utils/python/modtool/tests/test_modtool.py
+++ b/gr-utils/python/modtool/tests/test_modtool.py
@@ -1,5 +1,5 @@
#
-# Copyright 2018 Free Software Foundation, Inc.
+# Copyright 2018, 2019 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -35,7 +35,13 @@ try:
except:
skip_pylint_test = True
-from gnuradio.modtool.core import *
+from modtool.core import ModToolNewModule
+from modtool.core import ModToolAdd
+from modtool.core import ModToolDisable
+from modtool.core import ModToolException
+from modtool.core import ModToolMakeYAML
+from modtool.core import ModToolRename
+from modtool.core import ModToolRemove
class TestModToolCore(unittest.TestCase):
""" The tests for the modtool core """
@@ -43,6 +49,7 @@ class TestModToolCore(unittest.TestCase):
super(TestModToolCore, self).__init__(*args, **kwargs)
self.f_add = False
self.f_newmod = False
+ self.srcdir = path.abspath(path.join(path.dirname(path.realpath(__file__)), '../templates/gr-newmod'))
@classmethod
def setUpClass(cls):
@@ -58,7 +65,9 @@ class TestModToolCore(unittest.TestCase):
""" create a new module and block before every test """
try:
warnings.simplefilter("ignore", ResourceWarning)
- args = {'module_name':'howto', 'directory': self.test_dir}
+ args = {'module_name':'howto',
+ 'directory': self.test_dir,
+ 'srcdir': self.srcdir}
ModToolNewModule(**args).run()
except (TypeError, ModToolException):
self.f_newmod = True
@@ -83,8 +92,8 @@ class TestModToolCore(unittest.TestCase):
def test_newmod(self):
""" Tests for the API function newmod """
## Tests for proper exceptions ##
- test_dict = {}
- test_dict['directory'] = self.test_dir
+ test_dict = { 'directory': self.test_dir,
+ 'srcdir': self.srcdir}
# module name not specified
self.assertRaises(ModToolException, ModToolNewModule(**test_dict).run)
test_dict['module_name'] = 'howto'
@@ -108,9 +117,10 @@ class TestModToolCore(unittest.TestCase):
self.assertTrue(path.exists(path.join(module_dir, 'CMakeLists.txt')))
## The check for object instantiation ##
- test_obj = ModToolNewModule()
+ test_obj = ModToolNewModule(srcdir = self.srcdir)
# module name not specified
- self.assertRaises(ModToolException, test_obj.run)
+ with self.assertRaises(ModToolException) as context_manager:
+ test_obj.run()
test_obj.info['modname'] = 'howto'
test_obj.directory = self.test_dir
# directory already exists