def create_suite_runner(outfile, xmlout, parser=None, verbosity=1): outfile = Path(outfile) xmlout = Path(xmlout) # Add tests to this container test_cls = deepcopy(TestContainer) # Fail fast essentially if the outfile does not exist if not outfile.exists(): log("out file does not exist: {}".format(str(outfile)), logger="parser") test_cls.add_outfile_exists_test(outfile) runner, suite = make_suite_runner(test_cls, verbosity, xmlout) # If the outfile exists, parse it for results else: # Create summary tests for the unit test targets basic = summarize_test_outfile(str(outfile.absolute())) for v in basic.values(): test_cls.add_test(v, parser=parser) # Create tests for each line in the all_tests out file full = full_parse_all_tests(str(outfile.absolute())) for v in full.values(): test_cls.add_test(v, parser=parser) runner, suite = make_suite_runner(test_cls, verbosity, xmlout) return suite, runner
def make_circleci_config(outfile, artifacts, logpath): """Write a CircleCI configuration file to the path OUTFILE using the esmf-test-artifacts directory ARTIFACTS.""" env.ESMF_TEST_ARTIFACTS = artifacts logger = 'make-circleci-config' etlog.log.configure(to_file=logpath, to_stream=True) etlog.log('Starting...', logger=logger) make_config_circleci(outfile) etlog.log('Success', logger=logger)
def run_artifact_tests(artifacts, xmlout, branch, platform, compiler, comm): env.ESMF_TEST_ARTIFACTS = artifacts run_filter = {'branch': branch, 'platform': platform, 'compiler': compiler, 'comm': comm} seen_outfiles = set() for parser in Parser.iter_parsers(): checks = [] for k, v in run_filter.items(): check = False if v is not None: if parser.config[k] == v: check = True else: check = True checks.append(check) if all(checks): log("Running tests with config: {}".format(parser.config), logger='run') for outfile in OUTFILES: log("Testing out file: {}".format(outfile)) outfile = os.path.join(parser.results_dir, 'out', outfile) if outfile in seen_outfiles: raise ValueError("out file already processed: {}".format(outfile)) seen_outfiles.update([outfile]) suite, runner = create_suite_runner(outfile, xmlout, parser=parser) runner.run(suite)
def check_outfile(outfile, xmlout, logpath): logger = 'check-outfile' etlog.log.configure(to_file=logpath, to_stream=True) etlog.log('Starting...', logger=logger) if xmlout is None: xmlout = tempfile.mkdtemp() etlog.log( '"xmlout" not provided. Writing to temporary directory: {}'.format( xmlout), logger=logger) suite, runner = create_suite_runner(outfile, xmlout) runner.run(suite) etlog.log('Success', logger=logger)
def iter_test_meta(self): """DEPRECATED! Create test metadata from test log files.""" expr = re.compile(REGEXPS['log_line']) test_target = self.config['test_target'] # Loop for each test target: examples, unit_tests, system_tests target_dir = os.path.join(self.results_dir, TARGET_META[test_target]['dir']) # Loop for each file in the test output directory for de in os.scandir(target_dir): # Only select files with appropriate suffix (i.e. STest.Log) if de.name.endswith(TARGET_META[test_target]['suffix']): logpath = Path(de.path) stdout = Path(os.path.join(target_dir, os.path.splitext(logpath.name)[0] + '.stdout')) if self.debug: log("current log={}".format(de.path), level=DEBUG) current_test = None meta = OrderedDict() with open(de.path, 'r') as logfile: lines = logfile.readlines() for ctr, line in enumerate(lines, start=1): line = line.strip() match = re.match(expr, line) if match is not None: gd = match.groupdict() if self.debug: log("current match={}".format(gd), level=DEBUG) if gd['msg'] != current_test: current_test = gd['msg'] if self.debug: log("creating new test={}".format(current_test)) meta[current_test] = {'logfile': logpath, 'stdout': stdout, 'lines': []} append_to = meta[current_test]['lines'] if gd['msg'] == current_test: gd['parsed_line'] = ctr gd['raw'] = line gd['test_target'] = test_target append_to.append(gd) yield meta
def artifact_tests(artifacts, xmlout, branch, platform, compiler, comm, logpath): etlog.log.configure(to_file=logpath, to_stream=True) etlog.log('Starting...', logger=LOGGER) run_artifact_tests(artifacts, xmlout, branch, platform, compiler, comm) etlog.log('Success', logger=LOGGER)
def clone_git_repo(url, dst): multi_options = ['--depth 1'] log("Starting to clone ESMF Test Artifacts repository") git.Repo.clone_from(url, dst, multi_options=multi_options) log("Finished cloing ESMF Test Artifacts repository")