Add script to run tests locally

The script uses the test_description.json file to get the test
names and the commands to be run.

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
This commit is contained in:
Catalin Dumitru
2021-08-20 12:25:16 +03:00
committed by Andreea Florescu
parent cd3d97f923
commit 555474aaba
2 changed files with 68 additions and 0 deletions

39
test_run.py Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import json
import subprocess
import platform
import pathlib
import unittest
PARENT_DIR = pathlib.Path(__file__).parent.resolve()
class TestsContainer(unittest.TestCase):
pass
def make_test_function(command):
def test(self):
subprocess.run(command, shell=True, check=True)
return test
def retrieve_test_list(
config_file=f"{PARENT_DIR}/.buildkite/test_description.json"
):
with open(config_file) as jsonFile:
test_list = json.load(jsonFile)
jsonFile.close()
return test_list
if __name__ == '__main__':
test_config = retrieve_test_list()
for test in test_config['tests']:
command = test['command']
command = command.replace("{target_platform}", platform.machine())
test_func = make_test_function(command)
setattr(TestsContainer, 'test_{}'.format(test['test_name']), test_func)
unittest.main(verbosity=2)