mirror of https://github.com/ARMmbed/mbed-os.git
update test file generator
parent
3e7ee6c4d1
commit
e0e759e0a4
|
@ -203,7 +203,6 @@ Each class to be tested requires two files for unit testing:
|
||||||
|
|
||||||
A unit test definition file `unittest.cmake` requires variables to be set for a test to be configured. File source paths in `unittest.cmake` files need to be relative to the unit test folder and `CMakeLists.txt`.
|
A unit test definition file `unittest.cmake` requires variables to be set for a test to be configured. File source paths in `unittest.cmake` files need to be relative to the unit test folder and `CMakeLists.txt`.
|
||||||
|
|
||||||
* **TEST_SUITE_NAME** - Identifier for the test suite. Use naming convention *PATH_TO_THE_TESTABLE_FILE* e.g. *features-netsocket-InternetSocket*
|
|
||||||
* **unittest-includes** - Include paths for headers needed to build the tests in addition to the base include paths listed in [CMakeLists.txt](CMakeLists.txt). Optional.
|
* **unittest-includes** - Include paths for headers needed to build the tests in addition to the base include paths listed in [CMakeLists.txt](CMakeLists.txt). Optional.
|
||||||
* **unittest-sources** - Mbed OS source files and stubs included for the build.
|
* **unittest-sources** - Mbed OS source files and stubs included for the build.
|
||||||
* **unittest-test-sources** - Unit test source files.
|
* **unittest-test-sources** - Unit test source files.
|
||||||
|
@ -225,8 +224,6 @@ For example to create a unit test for `rtos/Semaphore.cpp`:
|
||||||
1. Create a directory for unit test files in `UNITTESTS/rtos/Semaphore`.
|
1. Create a directory for unit test files in `UNITTESTS/rtos/Semaphore`.
|
||||||
2. Create a test definition file `UNITTESTS/rtos/Semaphore/unittest.cmake` with the following content:
|
2. Create a test definition file `UNITTESTS/rtos/Semaphore/unittest.cmake` with the following content:
|
||||||
```
|
```
|
||||||
set(TEST_SUITE_NAME "rtos-Semaphore")
|
|
||||||
|
|
||||||
set(unittest-sources
|
set(unittest-sources
|
||||||
stubs/mbed_assert.c
|
stubs/mbed_assert.c
|
||||||
../rtos/Semaphore.cpp
|
../rtos/Semaphore.cpp
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
# UNIT TESTS
|
# UNIT TESTS
|
||||||
####################
|
####################
|
||||||
|
|
||||||
# Unit test suite name
|
|
||||||
set(TEST_SUITE_NAME "suitename")
|
|
||||||
|
|
||||||
set(unittest-includes ${unittest-includes}
|
set(unittest-includes ${unittest-includes}
|
||||||
headerfile
|
headerfile
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,7 +28,7 @@ class UnitTestGeneratorTool(object):
|
||||||
Generator tool to create new unit tests from template
|
Generator tool to create new unit tests from template
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _replace_content(self, template_content, dirname, classname, suite_name, extension):
|
def _replace_content(self, template_content, dirname, classname, extension):
|
||||||
if extension == "h":
|
if extension == "h":
|
||||||
content = re.sub(r"cppfile",
|
content = re.sub(r"cppfile",
|
||||||
"",
|
"",
|
||||||
|
@ -41,7 +41,6 @@ class UnitTestGeneratorTool(object):
|
||||||
content = re.sub(r"headerfile", "../dirname/template.h", content)
|
content = re.sub(r"headerfile", "../dirname/template.h", content)
|
||||||
content = re.sub(r"dirname", dirname, content)
|
content = re.sub(r"dirname", dirname, content)
|
||||||
content = re.sub(r"template", classname, content)
|
content = re.sub(r"template", classname, content)
|
||||||
content = re.sub(r"suitename", suite_name, content)
|
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
@ -111,7 +110,6 @@ class UnitTestGeneratorTool(object):
|
||||||
content = self._replace_content(template_content,
|
content = self._replace_content(template_content,
|
||||||
dir_name,
|
dir_name,
|
||||||
class_name,
|
class_name,
|
||||||
suite_name,
|
|
||||||
file_extension)
|
file_extension)
|
||||||
|
|
||||||
output_file.writelines(content)
|
output_file.writelines(content)
|
||||||
|
@ -130,7 +128,6 @@ class UnitTestGeneratorTool(object):
|
||||||
content = self._replace_content(template_content,
|
content = self._replace_content(template_content,
|
||||||
dir_name,
|
dir_name,
|
||||||
class_name,
|
class_name,
|
||||||
suite_name,
|
|
||||||
file_extension)
|
file_extension)
|
||||||
|
|
||||||
output_file.writelines(content)
|
output_file.writelines(content)
|
||||||
|
|
Loading…
Reference in New Issue