def test_processing_errors(mocked_post_processor: Postprocessor, mocked_test_kvs_failure: Dict[str, Any]) -> None: test_kvs = mocked_test_kvs_failure mocked_post_processor.test_log_path = '/not/a/real/file.log' mocked_post_processor.set_fail_tags(test_kvs) assert 'processing_errors' in test_kvs assert 'fail_tags' not in test_kvs
def test_add_fail_tag_multiline(mocked_post_processor: Postprocessor, mocked_test_kvs_failure: Dict[str, Any], tmp_path: pathlib.Path) -> None: test_kvs = mocked_test_kvs_failure test_log = tmp_path / 'failed_test.log' test_log.write_text(LOG_CONTENTS + 'SIGINT\n' * 2 + 'SIGKILL\n' * 3 + 'SIGSEGV\n' * 4, encoding='utf-8') mocked_post_processor.test_log_path = str(test_log) mocked_post_processor.set_fail_tags(test_kvs) assert 'fail_tags' in test_kvs assert len(test_kvs['fail_tags']) == 3 assert test_kvs['fail_tags'] == [ 'signal_SIGINT', 'signal_SIGKILL', 'signal_SIGSEGV' ]
def test_add_fail_tag_failures(mocked_post_processor: Postprocessor, mocked_test_kvs_failure: Dict[str, Any], error_text: str, expected_tag: str, tmpdir: py.path.local) -> None: test_kvs = mocked_test_kvs_failure # Write to temp file using built-in pytest fixture under /tmp/pytest-of-$USER/pytest-current # Temp directories older than 3 most recent runs are automatically removed. test_log = tmpdir / 'failed_test.log' test_log.write_text(LOG_CONTENTS + error_text, encoding='utf-8') mocked_post_processor.test_log_path = test_log.strpath mocked_post_processor.set_fail_tags(test_kvs) assert 'fail_tags' in test_kvs if expected_tag.startswith('signal_'): assert test_kvs['fail_tags'] == [expected_tag.format(error_text)] else: assert test_kvs['fail_tags'] == [expected_tag]
def mocked_post_processor() -> Postprocessor: return Postprocessor([ # type: ignore '--yb-src-root', 'not_a_real_dir', '--build-root', ' not_a_real_dir', '--test-log-path', 'not_a_real_dir/StringUtilTest_MatchPatternTest.log', '--junit-xml-path', ' not_a_real_dir/StringUtilTest_MatchPatternTest.xml', '--language', 'cxx' ])
def test_add_fail_tags_success( mocked_post_processor: Postprocessor, mocked_test_kvs_success: Dict[str, Any]) -> None: test_kvs = mocked_test_kvs_success mocked_post_processor.set_fail_tags(test_kvs) assert 'fail_tags' not in test_kvs