Skip to content

Commit 8295fab

Browse files
committed
script update
1 parent 8436c6d commit 8295fab

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/scripts/run_smoke_tests.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
def 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')
1213
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'
1318

1419
smoke_tests_dir = os.path.join(args.testDir, "generated/smoke-tests")
1520

@@ -35,13 +40,17 @@ def main():
3540
for service in services:
3641
executable = os.path.join(smoke_tests_dir, service, f"{service}-smoke-tests")
3742

38-
with tempfile.NamedTemporaryFile(mode='w+', suffix='.json') as temp_file:
39-
json_output_path = temp_file.name
43+
fd, json_output_path = tempfile.mkstemp(suffix='.json')
44+
os.close(fd) # Close the file descriptor so subprocess can write
45+
46+
try:
4047
test_command = [executable, f'--gtest_output=json:{json_output_path}']
4148
subprocess.run(test_command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
4249

4350
with open(json_output_path, 'r') as f:
4451
test_results = json.load(f)
52+
finally:
53+
os.unlink(json_output_path)
4554

4655
for test_suite in test_results.get('testsuites', []):
4756
total_tests += test_suite['tests']

0 commit comments

Comments
 (0)