| junit.py (c86abd2bd7bbd3f166f6091e334a85cda113e4a2) | junit.py (4d00b080eb3f95d2e04e55c0ff369c5c847bb288) |
|---|---|
| 1#!/usr/bin/env python3 2from junit_common import * 3 4 5def create_argparser() -> argparse.ArgumentParser: 6 """Creates argument parser to read command line arguments 7 8 Returns: --- 13 unchanged lines hidden (view full) --- 22 type=RunMode, 23 action=CaseInsensitiveEnumAction, 24 help='Output mode, junit or tap', 25 default=RunMode.JUNIT) 26 parser.add_argument('-n', '--nproc', type=int, default=1, help='number of MPI processes') 27 parser.add_argument('-o', '--output', type=Optional[Path], default=None, help='Output file to write test') 28 parser.add_argument('-b', '--junit-batch', type=str, default='', help='Name of JUnit batch for output file') 29 parser.add_argument('-np', '--pool-size', type=int, default=1, help='Number of test cases to run in parallel') | 1#!/usr/bin/env python3 2from junit_common import * 3 4 5def create_argparser() -> argparse.ArgumentParser: 6 """Creates argument parser to read command line arguments 7 8 Returns: --- 13 unchanged lines hidden (view full) --- 22 type=RunMode, 23 action=CaseInsensitiveEnumAction, 24 help='Output mode, junit or tap', 25 default=RunMode.JUNIT) 26 parser.add_argument('-n', '--nproc', type=int, default=1, help='number of MPI processes') 27 parser.add_argument('-o', '--output', type=Optional[Path], default=None, help='Output file to write test') 28 parser.add_argument('-b', '--junit-batch', type=str, default='', help='Name of JUnit batch for output file') 29 parser.add_argument('-np', '--pool-size', type=int, default=1, help='Number of test cases to run in parallel') |
| 30 parser.add_argument('-s', '--smartredis_dir', type=str, default='', help='path to SmartSim library, if present') |
|
| 30 parser.add_argument('test', help='Test executable', nargs='?') 31 32 return parser 33 34 35# Necessary functions for running tests 36class CeedSuiteSpec(SuiteSpec): 37 def get_source_path(self, test: str) -> Path: --- 151 unchanged lines hidden (view full) --- 189 return test[:4] in ['t003'] 190 191 192if __name__ == '__main__': 193 args = create_argparser().parse_args() 194 195 # run tests 196 if 'smartsim' in args.test: | 31 parser.add_argument('test', help='Test executable', nargs='?') 32 33 return parser 34 35 36# Necessary functions for running tests 37class CeedSuiteSpec(SuiteSpec): 38 def get_source_path(self, test: str) -> Path: --- 151 unchanged lines hidden (view full) --- 190 return test[:4] in ['t003'] 191 192 193if __name__ == '__main__': 194 args = create_argparser().parse_args() 195 196 # run tests 197 if 'smartsim' in args.test: |
| 197 sys.path.insert(0, str(Path(__file__).parents[1] / "examples" / "fluids")) 198 from smartsim_regression_framework import SmartSimTest 199 200 test_framework = SmartSimTest(Path(__file__).parent / 'test_dir') 201 test_framework.setup() | 198 has_smartsim: bool = args.smartredis_dir and Path(args.smartredis_dir).is_file() |
| 202 test_cases = [] | 199 test_cases = [] |
| 203 print(f'1..1') 204 is_new_subtest = True 205 subtest_ok = True 206 for i, backend in enumerate(args.ceed_backends): 207 test_cases.append(test_framework.test_junit(backend)) 208 if is_new_subtest and args.mode == RunMode.TAP: 209 is_new_subtest = False 210 print(f'# Subtest: {test_cases[0].category}') 211 print(f' 1..{len(args.ceed_backends)}') 212 print(test_case_output_string(test_cases[i], TestSpec("SmartSim Tests"), args.mode, backend, '', i)) 213 if args.mode == RunMode.TAP: 214 print(f'{"" if subtest_ok else "not "}ok 1 - {test_cases[0].category}') 215 test_framework.teardown() | 200 201 if args.mode is RunMode.TAP: 202 print(f'1..1') 203 if has_smartsim: 204 sys.path.insert(0, str(Path(__file__).parents[1] / "examples" / "fluids")) 205 from smartsim_regression_framework import SmartSimTest 206 207 test_framework = SmartSimTest(Path(__file__).parent / 'test_dir') 208 test_framework.setup() 209 210 is_new_subtest = True 211 subtest_ok = True 212 for i, backend in enumerate(args.ceed_backends): 213 test_cases.append(test_framework.test_junit(backend)) 214 if is_new_subtest and args.mode == RunMode.TAP: 215 is_new_subtest = False 216 print(f'# Subtest: {test_cases[0].category}') 217 print(f' 1..{len(args.ceed_backends)}') 218 print(test_case_output_string(test_cases[i], TestSpec("SmartSim Tests"), args.mode, backend, '', i)) 219 if args.mode == RunMode.TAP: 220 print(f'{"" if subtest_ok else "not "}ok 1 - {test_cases[0].category}') 221 test_framework.teardown() 222 elif args.mode is RunMode.TAP: 223 print(f'ok 1 - # SKIP SmartSim not installed') |
| 216 result: TestSuite = TestSuite('SmartSim Tests', test_cases) 217 else: 218 result: TestSuite = run_tests( 219 args.test, 220 args.ceed_backends, 221 args.mode, 222 args.nproc, 223 CeedSuiteSpec(), 224 args.pool_size) 225 226 # write output and check for failures 227 if args.mode is RunMode.JUNIT: 228 write_junit_xml(result, args.output, args.junit_batch) 229 if has_failures(result): 230 sys.exit(1) | 224 result: TestSuite = TestSuite('SmartSim Tests', test_cases) 225 else: 226 result: TestSuite = run_tests( 227 args.test, 228 args.ceed_backends, 229 args.mode, 230 args.nproc, 231 CeedSuiteSpec(), 232 args.pool_size) 233 234 # write output and check for failures 235 if args.mode is RunMode.JUNIT: 236 write_junit_xml(result, args.output, args.junit_batch) 237 if has_failures(result): 238 sys.exit(1) |