def test_multiple(self): test_log = """[ RUN ] SimpleTest.TestCase1 [ OK ] SimpleTest.TestCase1 (10 ms) [ RUN ] SimpleTest.TestCase2 [ OK ] SimpleTest.TestCase2 (9 ms) [ RUN ] SimpleTest.TestCase3 [ OK ] SimpleTest.TestCase3 (8 ms) """ self.assertEqual( { "SimpleTest.TestCase1": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 10, "test_prefix": "", "log": "", }, "SimpleTest.TestCase2": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 9, "test_prefix": "", "log": "", }, "SimpleTest.TestCase3": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 8, "test_prefix": "", "log": "", }, }, gtest_parser.parse(test_log), )
def test_crash_log_not_last(self): test_log = """[ RUN ] SimpleTest.TestCase test/test.cc:123: Some Failure Haaaaang! Craaaaaassssshhhhhh! [ RUN ] SimpleTest.TestCase2 something [ OK ] SimpleTest.TestCase2 (9 ms) """ self.assertEqual( { "SimpleTest.TestCase": { "is_successful": False, "is_crash_or_hang": True, "run_time_ms": -1, "test_prefix": "", "log": """test/test.cc:123: Some Failure Haaaaang! Craaaaaassssshhhhhh!""", }, "SimpleTest.TestCase2": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 9, "test_prefix": "", "log": "something", }, }, gtest_parser.parse(test_log), )
def insert_gtest_results(build_step_key): """Inserts GTest results into the datastore, replacing any existing ones. Also records used parser version.""" step = BuildStep.get(build_step_key) log_contents = '' if step.log_gs: with cloudstorage.open(step.log_gs) as gs_file: log_contents = html2text(gs_file.read().decode('utf-8', 'replace')) else: try: blob_reader = blobstore.BlobReader(step.log_stdio) log_contents = html2text(blob_reader.read().decode('utf-8', 'replace')) except (ValueError, blobstore.BlobNotFoundError) as e: raise deferred.PermanentTaskFailure(e) gtest_results = gtest_parser.parse(log_contents) to_put = [] for fullname, result in gtest_results.iteritems(): # Only store failure results. if result['is_successful']: continue if isinstance(result['log'], unicode): log = db.Text(result['log']) else: log = db.Text(result['log'], encoding='utf-8') result_entity = GTestResult(parent=db.Key.from_path( 'GTestResult', str(step.key())), build_step=step, time_finished=step.time_finished, gtest_parser_version=gtest_parser.VERSION, is_crash_or_hang=result['is_crash_or_hang'], fullname=fullname, run_time_ms=result['run_time_ms'], log=log) to_put.append(result_entity) for chunk in chunks(to_put, BATCH_SIZE): db.put(chunk) def tx_parser_version(): step = BuildStep.get(build_step_key) orig_parser_version = step.gtest_parser_version if step.gtest_parser_version < gtest_parser.VERSION: step.gtest_parser_version = gtest_parser.VERSION step.put() return (orig_parser_version, step.gtest_parser_version) _, parser_version = \ db.run_in_transaction_custom_retries(10, tx_parser_version) query = GTestResult.all(keys_only=True) query.filter('build_step =', build_step_key) query.filter('gtest_parser_version <', parser_version) db.delete(query)
def test_line_endings2(self): test_log = "[ RUN ] SimpleTest.TestCase\r\r\n" + "[ OK ] SimpleTest.TestCase (42 ms)\r\r\n" self.assertEqual( { "SimpleTest.TestCase": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 42, "test_prefix": "", "log": "", } }, gtest_parser.parse(test_log), )
def test_crash(self): test_log = """[ RUN ] SimpleTest.TestCase """ self.assertEqual( { "SimpleTest.TestCase": { "is_successful": False, "is_crash_or_hang": True, "run_time_ms": -1, "test_prefix": "", "log": "", } }, gtest_parser.parse(test_log), )
def test_truncate(self): test_log = "\n".join( ["[ RUN ] SimpleTest.TestCase"] + ["a" * 5000] + ["[ OK ] SimpleTest.TestCase (42 ms)"] ) self.assertEqual( { "SimpleTest.TestCase": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 42, "test_prefix": "", "log": "a" * 120 + " (truncated by parser)", } }, gtest_parser.parse(test_log), )
def test_fail(self): test_log = """[ RUN ] SimpleTest.TestCase test/test.cc:123: Some Failure [ FAILED ] SimpleTest.TestCase (18 ms) """ self.assertEqual( { "SimpleTest.TestCase": { "is_successful": False, "is_crash_or_hang": False, "run_time_ms": 18, "test_prefix": "", "log": "test/test.cc:123: Some Failure", } }, gtest_parser.parse(test_log), )
def test_single_params(self): test_log = """[ RUN ] ExtensionDevToolsBrowserTest.FLAKY_TimelineApi /b/build/slave/chromium-mac-flaky-builder-dbg/build/src/chrome/browser/extensions/extension_devtools_browsertests.cc:90: Failure Value of: result Actual: false Expected: true [ FAILED ] ExtensionDevToolsBrowserTest.FLAKY_TimelineApi, where TypeParam = and GetParam() = (814 ms)""" self.assertEqual({ 'ExtensionDevToolsBrowserTest.TimelineApi': { 'is_successful': False, 'is_crash_or_hang': False, 'run_time_ms': 814, 'test_prefix': 'FLAKY', 'log': """/b/build/slave/chromium-mac-flaky-builder-dbg/build/src/chrome/browser/extensions/extension_devtools_browsertests.cc:90: (truncated by parser) Value of: result Actual: false Expected: true""" } }, gtest_parser.parse(test_log))
def test_multiple_noise(self): test_log = """noise-noise [ RUN ] SimpleTest.TestCase1 [ OK ] SimpleTest.TestCase1 (10 ms) [ RUN ] SimpleTest.TestCase2 [ OK ] SimpleTest.TestCase2 (9 ms) [ -- - ] some more noise garbagegarbage [ RUN ] SimpleTest.TestCase3 real log second line [ OK ] SimpleTest.TestCase3 (8 ms) """ self.assertEqual( { "SimpleTest.TestCase1": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 10, "test_prefix": "", "log": "", }, "SimpleTest.TestCase2": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 9, "test_prefix": "", "log": "", }, "SimpleTest.TestCase3": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 8, "test_prefix": "", "log": "real log\nsecond line", }, }, gtest_parser.parse(test_log), )
def test_trim(self): test_log = "\n".join( ["[ RUN ] SimpleTest.TestCase"] + [str(x) for x in range(1000)] + ["[ OK ] SimpleTest.TestCase (42 ms)"] ) self.assertEqual( { "SimpleTest.TestCase": { "is_successful": True, "is_crash_or_hang": False, "run_time_ms": 42, "test_prefix": "", "log": "\n".join( [str(x) for x in range(22)] + ["", "(trimmed by parser)", ""] + [str(x) for x in range(977, 1000)] ), } }, gtest_parser.parse(test_log), )
def test_single_params(self): test_log = """[ RUN ] ExtensionDevToolsBrowserTest.FLAKY_TimelineApi /b/build/slave/chromium-mac-flaky-builder-dbg/build/src/chrome/browser/extensions/extension_devtools_browsertests.cc:90: Failure Value of: result Actual: false Expected: true [ FAILED ] ExtensionDevToolsBrowserTest.FLAKY_TimelineApi, where TypeParam = and GetParam() = (814 ms)""" self.assertEqual( { "ExtensionDevToolsBrowserTest.TimelineApi": { "is_successful": False, "is_crash_or_hang": False, "run_time_ms": 814, "test_prefix": "FLAKY", "log": """/b/build/slave/chromium-mac-flaky-builder-dbg/build/src/chrome/browser/extensions/extension_devtools_browsertests.cc:90: (truncated by parser) Value of: result Actual: false Expected: true""", } }, gtest_parser.parse(test_log), )
def test_multiple_noise(self): test_log = """noise-noise [ RUN ] SimpleTest.TestCase1 [ OK ] SimpleTest.TestCase1 (10 ms) [ RUN ] SimpleTest.TestCase2 [ OK ] SimpleTest.TestCase2 (9 ms) [ -- - ] some more noise garbagegarbage [ RUN ] SimpleTest.TestCase3 real log second line [ OK ] SimpleTest.TestCase3 (8 ms) """ self.assertEqual({ 'SimpleTest.TestCase1': { 'is_successful': True, 'is_crash_or_hang': False, 'run_time_ms': 10, 'test_prefix': '', 'log': '', }, 'SimpleTest.TestCase2': { 'is_successful': True, 'is_crash_or_hang': False, 'run_time_ms': 9, 'test_prefix': '', 'log': '', }, 'SimpleTest.TestCase3': { 'is_successful': True, 'is_crash_or_hang': False, 'run_time_ms': 8, 'test_prefix': '', 'log': 'real log\nsecond line', } }, gtest_parser.parse(test_log))
def test_android_noise_2(self): test_log = '[014E0F500401B017] # 2012-09-28 12:13:19,537: >>> $am force-stop com.google.android.apps.chrome' self.assertEqual({}, gtest_parser.parse(test_log))
def test_info_noise_1(self): test_log = '[----------] Global test environment set-up.' self.assertEqual({}, gtest_parser.parse(test_log))
def test_buildbot_noise(self): test_log = """<pre><span class="header">python ../../../scripts/slave/runtest.py --target Release --build-dir src/build '--build-properties={"blamelist":"[email protected],[email protected]","branch":"src","buildername":"Mac10.7 Tests (1)","buildnumber":"2247","got_revision":"159081","mastername":"chromium.mac","parent_builddir":"","parent_buildnumber":"1007","parentname":"Mac Builder","parentslavename":"xserve6-m1","revision":"159081","scheduler":"mac_rel_trigger","slavename":"vm614-m1"}' '--factory-properties={"browser_shard_index":1,"browser_total_shards":3,"gclient_env":{"DEPOT_TOOLS_UPDATE":"0","GYP_DEFINES":" component=static_library","GYP_GENERATOR_FLAGS":""},"generate_gtest_json":true,"sharded_tests":["base_unittests","browser_tests","cc_unittests","content_browsertests","media_unittests","webkit_compositor_bindings_unittests"]}' --annotate=gtest --test-type gpu_unittests --generate-json-file -o gtest-results/gpu_unittests --build-number 2247 --builder-name 'Mac10.7 Tests (1)' gpu_unittests --gmock_verbose=error --gtest_print_time""" self.assertEqual({}, gtest_parser.parse(test_log))
def test_gtest_threads_noise(self): test_log = "[WARNING] /b/build/slave/cr-mac-rel/build/src/testing/gtest/src/gtest-death-test.cc:827:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 4 threads." self.assertEqual({}, gtest_parser.parse(test_log))
def test_info_noise_2(self): test_log = "[ PASSED ] 0 tests. " self.assertEqual({}, gtest_parser.parse(test_log))
def test_info_noise_1(self): test_log = "[----------] Global test environment set-up." self.assertEqual({}, gtest_parser.parse(test_log))
def test_info_noise_2(self): test_log = '[ PASSED ] 0 tests. ' self.assertEqual({}, gtest_parser.parse(test_log))
def test_gtest_threads_noise(self): test_log = '[WARNING] /b/build/slave/cr-mac-rel/build/src/testing/gtest/src/gtest-death-test.cc:827:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 4 threads.' self.assertEqual({}, gtest_parser.parse(test_log))
def test_empty(self): self.assertEqual({}, gtest_parser.parse(""))
def test_android_noise_2(self): test_log = "[014E0F500401B017] # 2012-09-28 12:13:19,537: >>> $am force-stop com.google.android.apps.chrome" self.assertEqual({}, gtest_parser.parse(test_log))
def test_empty(self): self.assertEqual({}, gtest_parser.parse(''))