Load JSON config and call relevant functions to run chosen test suites.
()
| 258 | |
| 259 | |
| 260 | def main(): |
| 261 | """ |
| 262 | Load JSON config and call relevant functions to run chosen test suites. |
| 263 | """ |
| 264 | test_cmd, test_suites, config_file, output_path, verbose = parse_args() |
| 265 | if test_cmd is None or not os.path.isfile(test_cmd): |
| 266 | print("Invalid filepath for perf test app!") |
| 267 | return |
| 268 | try: |
| 269 | with open(config_file) as conf: |
| 270 | test_suite_ops = json.load(conf) |
| 271 | config_name = os.path.splitext(config_file)[0] |
| 272 | if '/' in config_name: |
| 273 | config_name = config_name.rsplit('/', 1)[1] |
| 274 | output_path = os.path.join(output_path, config_name, "") |
| 275 | print("Using config: " + config_file) |
| 276 | except OSError as err: |
| 277 | print("Error with JSON file path: " + err.strerror) |
| 278 | return |
| 279 | except json.decoder.JSONDecodeError as err: |
| 280 | print("Error loading JSON config: " + err.msg) |
| 281 | return |
| 282 | |
| 283 | if test_suites != ["all"]: |
| 284 | suite_list = [] |
| 285 | for (suite, test_cases) in {k: v for (k, v) in test_suite_ops.items() |
| 286 | if k in test_suites}.items(): |
| 287 | suite_list.append(suite) |
| 288 | suite_config = {'config_name': config_name, 'suite': suite, |
| 289 | 'test_cases': test_cases, |
| 290 | 'output_path': output_path} |
| 291 | run_test_suite(test_cmd, suite_config, verbose) |
| 292 | if not suite_list: |
| 293 | print("No valid test suites chosen!") |
| 294 | return |
| 295 | else: |
| 296 | for (suite, test_cases) in test_suite_ops.items(): |
| 297 | suite_config = {'config_name': config_name, 'suite': suite, |
| 298 | 'test_cases': test_cases, |
| 299 | 'output_path': output_path} |
| 300 | run_test_suite(test_cmd, suite_config, verbose) |
| 301 | |
| 302 | graph_path = os.path.join(output_path, GRAPH_DIR, "") |
| 303 | if os.path.exists(graph_path): |
| 304 | shutil.rmtree(graph_path) |
| 305 | |
| 306 | |
| 307 | if __name__ == "__main__": |
no test coverage detected