Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2361)

Unified Diff: appengine/findit/crash/test/crash_report_test.py

Issue 2663063007: [Predator] Switch from anonymous dict to CrashData. (Closed)
Patch Set: Rebase and fix delta test. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/findit/crash/test/crash_report_test.py
diff --git a/appengine/findit/crash/test/crash_report_test.py b/appengine/findit/crash/test/crash_report_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..ae80f97325ddd698e1b917f6616d48ab36b6dea1
--- /dev/null
+++ b/appengine/findit/crash/test/crash_report_test.py
@@ -0,0 +1,133 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import copy
+
+from common.chrome_dependency_fetcher import ChromeDependencyFetcher
+from common.dependency import Dependency
+from common.dependency import DependencyRoll
+from crash.crash_report import CrashReport
+from crash.crash_report import _FrozenDict
+from crash.stacktrace import CallStack
+from crash.stacktrace import StackFrame
+from crash.stacktrace import Stacktrace
+from crash.test.crash_test_suite import CrashTestSuite
+from crash.type_enums import CallStackFormatType
+from crash.type_enums import LanguageType
+from libs.gitiles.change_log import ChangeLog
+from libs.gitiles.gitiles_repository import GitilesRepository
+
+DUMMY_CHANGELOG1 = ChangeLog.FromDict({
+ 'author': {
+ 'name': 'r@chromium.org',
+ 'email': 'r@chromium.org',
+ 'time': 'Thu Mar 31 21:24:43 2016',
+ },
+ 'committer': {
+ 'email': 'r@chromium.org',
+ 'time': 'Thu Mar 31 21:28:39 2016',
+ 'name': 'example@chromium.org',
+ },
+ 'message': 'dummy',
+ 'commit_position': 175900,
+ 'touched_files': [
+ {
+ 'change_type': 'add',
+ 'new_path': 'a.cc',
+ 'old_path': None,
+ },
+ ],
+ 'commit_url': 'https://repo.test/+/1',
+ 'code_review_url': 'https://codereview.chromium.org/3281',
+ 'revision': '1',
+ 'reverted_revision': None
+})
+
+DUMMY_CHANGELOG2 = ChangeLog.FromDict({
+ 'author': {
+ 'name': 'example@chromium.org',
+ 'email': 'example@chromium.org',
+ 'time': 'Thu Mar 31 21:24:43 2016',
+ },
+ 'committer': {
+ 'name': 'example@chromium.org',
+ 'email': 'example@chromium.org',
+ 'time': 'Thu Mar 31 21:28:39 2016',
+ },
+ 'message': 'dummy',
+ 'commit_position': 175976,
+ 'touched_files': [
+ {
+ 'change_type': 'add',
+ 'new_path': 'f0.cc',
+ 'old_path': 'b/f0.cc'
+ },
+ ],
+ 'commit_url': 'https://repo.test/+/2',
+ 'code_review_url': 'https://codereview.chromium.org/3281',
+ 'revision': '2',
+ 'reverted_revision': '1'
+})
+
+DUMMY_CHANGELOG3 = ChangeLog.FromDict({
+ 'author': {
+ 'name': 'e@chromium.org',
+ 'email': 'e@chromium.org',
+ 'time': 'Thu Apr 1 21:24:43 2016',
+ },
+ 'committer': {
+ 'name': 'example@chromium.org',
+ 'email': 'e@chromium.org',
+ 'time': 'Thu Apr 1 21:28:39 2016',
+ },
+ 'message': 'dummy',
+ 'commit_position': 176000,
+ 'touched_files': [
+ {
+ 'change_type': 'modify',
+ 'new_path': 'f.cc',
+ 'old_path': 'f.cc'
+ },
+ {
+ 'change_type': 'delete',
+ 'new_path': None,
+ 'old_path': 'f1.cc'
+ },
+ ],
+ 'commit_url': 'https://repo.test/+/3',
+ 'code_review_url': 'https://codereview.chromium.org/3281',
+ 'revision': '3',
+ 'reverted_revision': None
+})
+
+DUMMY_CALLSTACKS = [
+ CallStack(0, [], CallStackFormatType.DEFAULT, LanguageType.CPP),
+ CallStack(1, [], CallStackFormatType.DEFAULT, LanguageType.CPP)]
+DUMMY_REPORT = CrashReport(
+ None, None, None, Stacktrace(DUMMY_CALLSTACKS, DUMMY_CALLSTACKS[0]),
+ (None, None), None, None)
+
+
+class FrozenDictTest(CrashTestSuite):
+ def testHash(self):
+ """Test that ``_FrozenDict`` does not throw an exception in ``hash``."""
+ try:
+ _h = hash(_FrozenDict({'a': 1, 'b': 2, 'c': 3}))
+ except TypeError as e: # pragma: no cover
+ if 'unhashable type' in str(e):
+ self.fail('_FrozenDict.__hash__ does not work')
+ else:
+ raise e
+
+
+class CrashReportTest(CrashTestSuite):
+
+ def testDependenciesAndDependencyRollsIsFrozenDict(self):
+ crash_report = CrashReport(
+ 'rev', 'sig', 'win', None, ('1', '3'),
+ {'src/': Dependency('src/', 'http://repo', '5')},
+ {'src/': DependencyRoll('src/', 'http://repo', '1', '3')})
+ self.assertTrue(isinstance(crash_report.regression_range, tuple))
+ self.assertTrue(isinstance(crash_report.dependencies, _FrozenDict))
+ self.assertTrue(isinstance(crash_report.dependency_rolls, _FrozenDict))
« no previous file with comments | « appengine/findit/crash/test/crash_pipeline_test.py ('k') | appengine/findit/crash/test/crash_report_with_dependencies_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698