@@ -332,22 +332,30 @@ def _test(args: argparse.Namespace,
332332 test_status : bool = True
333333
334334 # Does the test have an 'ignore' declaration?
335+ # Obey it unless the test is named explicitly -
336+ # i.e. if th user has named a specific test, run it.
335337 if 'ignore' in job_definition .tests [job_test_name ]:
336- print ('W Ignoring test (found "ignore")' )
337- tests_ignored += 1
338- continue
338+ if args .test :
339+ print ('W Ignoring the ignore: property (told to run this test)' )
340+ else :
341+ print ('W Ignoring test (found "ignore")' )
342+ tests_ignored += 1
343+ continue
339344
340345 # Does the test have a 'run-level' declaration?
341346 # If so, is it higher than the run-level specified?
342- if 'run-level' in job_definition .tests [job_test_name ]:
343- run_level = job_definition .tests [job_test_name ]['run-level' ]
344- print (f'> run-level={ run_level } ' )
345- if run_level > args .run_level :
346- print (f'W Skipping test (test is "run-level: { run_level } ")' )
347- tests_skipped += 1
348- continue
347+ if args .test :
348+ print ('W Ignoring any run-level check (told to run this test)' )
349349 else :
350- print ('> run-level=Undefined' )
350+ if 'run-level' in job_definition .tests [job_test_name ]:
351+ run_level = job_definition .tests [job_test_name ]['run-level' ]
352+ print (f'> run-level={ run_level } ' )
353+ if run_level > args .run_level :
354+ print (f'W Skipping test (test is "run-level: { run_level } ")' )
355+ tests_skipped += 1
356+ continue
357+ else :
358+ print ('> run-level=Undefined' )
351359
352360 # Render the command for this test.
353361
@@ -460,7 +468,8 @@ def _test(args: argparse.Namespace,
460468 job_image_cores ,
461469 job_project_directory ,
462470 job_working_directory ,
463- job_command )
471+ job_command ,
472+ args .run_as_user )
464473 project_path : str = t_compose .create ()
465474
466475 test_path : str = t_compose .get_test_path ()
@@ -544,6 +553,17 @@ def arg_check_run_level(value: str) -> int:
544553 return i_value
545554
546555
556+ def arg_check_run_as_user (value : str ) -> int :
557+ """A type checker for the argparse run-as-user.
558+ """
559+ i_value = int (value )
560+ if i_value < 0 :
561+ raise argparse .ArgumentTypeError ('Minimum value is 0' )
562+ if i_value > 65_535 :
563+ raise argparse .ArgumentTypeError ('Maximum value is 65535' )
564+ return i_value
565+
566+
547567# -----------------------------------------------------------------------------
548568# main
549569# -----------------------------------------------------------------------------
@@ -582,6 +602,11 @@ def main() -> int:
582602 ' will be executed, a value from 1 to 100' ,
583603 default = 1 ,
584604 type = arg_check_run_level )
605+ arg_parser .add_argument ('-u' , '--run-as-user' ,
606+ help = 'A user ID to run the tests as. If not set'
607+ ' your user ID is used to run the test'
608+ ' containers.' ,
609+ type = arg_check_run_as_user )
585610
586611 arg_parser .add_argument ('-d' , '--dry-run' , action = 'store_true' ,
587612 help = 'Setting this flag will result in jote'
0 commit comments