Skip to content

Commit

Permalink
enable unit-test-config --live
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Sep 29, 2023
1 parent 45c5e4d commit 272cc50
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions unit-tests/unit-test-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ def usage():
print( ' --list-tests print out all available tests. This option will not run any tests' )
print( ' if both list-tags and list-tests are specified each test will be printed along' )
print( ' with what tags it has' )
print( ' --context The context to use for test configuration' )
print( ' --context The context to use for test configuration' )
print( ' --live Only configure tests that are live (have test:device)' )
sys.exit(2)

regex = None
required_tags = []
list_tags = False
list_tests = False
context = None
live_only = False
# parse command-line:
try:
opts, args = getopt.getopt( sys.argv[1:], 'hr:t:',
longopts=['help', 'regex=', 'tag=', 'list-tags', 'list-tests', 'context='] )
longopts=['help', 'regex=', 'tag=', 'list-tags', 'list-tests', 'context=', 'live'] )
except getopt.GetoptError as err:
log.e( err ) # something like "option -a not recognized"
usage()
Expand All @@ -63,6 +65,8 @@ def usage():
list_tests = True
elif opt == '--context':
context = arg
elif opt == '--live':
live_only = True

if len( args ) != 2:
usage()
Expand Down Expand Up @@ -190,7 +194,7 @@ def find_includes( filepath, filelist, dependencies ):
return filelist

def process_cpp( dir, builddir ):
global regex, required_tags, list_only, available_tags, tests_and_tags
global regex, required_tags, list_only, available_tags, tests_and_tags, live_only
found = []
shareds = []
statics = []
Expand All @@ -213,8 +217,8 @@ def process_cpp( dir, builddir ):
log.d( '... found:', f )
log.debug_indent()
try:
config = libci.TestConfigFromCpp( dir + os.sep + f, context )
if required_tags or list_tags:
config = libci.TestConfigFromCpp( dir + os.sep + f, context )
if not all( tag in config.tags for tag in required_tags ):
continue
available_tags.update( config.tags )
Expand All @@ -224,6 +228,10 @@ def process_cpp( dir, builddir ):
if testname not in tests_and_tags:
tests_and_tags[testname] = None

if live_only:
if not config.configurations:
continue

# Build the list of files we want in the project:
# At a minimum, we have the original file, plus any common files
filelist = [ dir + '/' + f, '${CATCH_FILES}' ]
Expand Down

0 comments on commit 272cc50

Please sign in to comment.