Skip to content

Commit

Permalink
CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MMirbach committed Feb 25, 2021
1 parent dc7beb0 commit 387f664
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions unit-tests/run-unit-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,19 @@ def __init__( self, testname, exe ):
self.exe = exe

# Finding the c/cpp file of the test to get the configuration
# TODO: this is limited to a structure in which .cpp files and directories do not share names
# For example:
# unit-tests/
# func/
# ...
# test-func.cpp
# test-func.cpp will not be found!
split_testname = testname.split( '-' )
cpp_path = current_dir
found_test_dir = False

while not found_test_dir:
# index 0 should be 'test' as tests always start with it
found_test_dir = True
for i in range(2, len(split_testname) ): # Checking if the next part of the test name is a sub-directory
tmp_path = cpp_path + os.sep + '-'.join(split_testname[1:i]) # The next sub-directory could have several words
Expand All @@ -393,10 +401,9 @@ def __init__( self, testname, exe ):
cpp_path += os.sep + '-'.join( split_testname )
if os.path.isfile( cpp_path + ".cpp" ):
cpp_path += ".cpp"
self._config = TestConfigFromText(cpp_path, r'//#\s*test:')
else:
cpp_path += ".c"

self._config = TestConfigFromText( cpp_path, r'//\s*#\s*test:' )
log.w( log.red + testname + log.reset + ':', 'No matching .cpp file was found; no configuration will be used!' )

@property
def command(self):
Expand Down

0 comments on commit 387f664

Please sign in to comment.