99def main ():
1010 parser = argparse .ArgumentParser (description = 'Run smoke tests' )
1111 parser .add_argument ('--testDir' , default = './build' , help = 'Path to build directory' )
12- parser .add_argument ('--test-failures' , action = 'store_true' , help = 'Use invalid credentials to test failure messages' )
1312 args = parser .parse_args ()
14-
15- if args .test_failures :
16- os .environ ['AWS_ACCESS_KEY_ID' ] = 'INVALID_KEY'
17- os .environ ['AWS_SECRET_ACCESS_KEY' ] = 'INVALID_SECRET'
1813
1914 smoke_tests_dir = os .path .join (args .testDir , "generated/smoke-tests" )
2015
@@ -33,8 +28,10 @@ def main():
3328
3429 total_tests = 0
3530 all_results = defaultdict (list )
31+ skipped_services = []
3632 service_id = os .environ .get ('AWS_SMOKE_TEST_SERVICE_IDS' , '' ).strip ().lower ().replace (' ' , '-' ) if os .environ .get ('AWS_SMOKE_TEST_SERVICE_IDS' , '' ).strip () else []
3733 if service_id :
34+ skipped_services = [s for s in services if s not in service_id ]
3835 services = [s for s in services if s in service_id ]
3936
4037 for service in services :
@@ -49,6 +46,8 @@ def main():
4946
5047 with open (json_output_path , 'r' ) as f :
5148 test_results = json .load (f )
49+ except (FileNotFoundError , json .JSONDecodeError ) as e :
50+ test_results = {}
5251 finally :
5352 os .unlink (json_output_path )
5453
@@ -65,6 +64,31 @@ def main():
6564 'failure' : failure_msg ,
6665 })
6766
67+ # Count skipped tests
68+ for service in skipped_services :
69+ executable = os .path .join (smoke_tests_dir , service , f"{ service } -smoke-tests" )
70+ fd , json_output_path = tempfile .mkstemp (suffix = '.json' )
71+ os .close (fd )
72+
73+ try :
74+ test_command = [executable , f'--gtest_output=json:{ json_output_path } ' ]
75+ subprocess .run (test_command , stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL )
76+ with open (json_output_path , 'r' ) as f :
77+ test_results = json .load (f )
78+ for test_suite in test_results .get ('testsuites' , []):
79+ total_tests += test_suite ['tests' ]
80+ for test in test_suite .get ('testsuite' , []):
81+ all_results [service ].append ({
82+ 'service' : service ,
83+ 'name' : test ['name' ],
84+ 'status' : 'SKIPPED' ,
85+ 'failure' : None ,
86+ })
87+ except (FileNotFoundError , json .JSONDecodeError ):
88+ pass
89+ finally :
90+ os .unlink (json_output_path )
91+
6892 print (f"1..{ total_tests } " )
6993
7094 for service in all_results .keys ():
@@ -76,7 +100,9 @@ def main():
76100 failure = result ['failure' ]
77101 error_expected = "error expected from service" if "Failure" in test_name or "Error" in test_name else "no error expected from service"
78102
79- if status == 'RUN' and not failure :
103+ if status == 'SKIPPED' :
104+ print (f"ok { service } { test_name } # SKIP" )
105+ elif status == 'RUN' and not failure :
80106 print (f"ok { service } { test_name } - { error_expected } " )
81107 else :
82108 print (f"not ok { service } { test_name } " )
0 commit comments