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

Unified Diff: telemetry/telemetry/testing/browser_test_context.py

Issue 2590623002: [Telemetry] Migrate browser_test_runner to use typ as the test runner (Closed)
Patch Set: Add missing options for typ Created 4 years 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: telemetry/telemetry/testing/browser_test_context.py
diff --git a/telemetry/telemetry/testing/browser_test_context.py b/telemetry/telemetry/testing/browser_test_context.py
new file mode 100644
index 0000000000000000000000000000000000000000..c6dcf28efcfef9db2f5e8ade2b80f13e5c2e9c03
--- /dev/null
+++ b/telemetry/telemetry/testing/browser_test_context.py
@@ -0,0 +1,64 @@
+# 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
+import sets
+
+
+_global_test_context = None
+
+
+def GetCopy():
+ return copy.deepcopy(_global_test_context)
+
+
+class TypTestContext(object):
+ """ The TestContext that is used for passing data from the main test process
+ to typ's subprocesses. Those includes:
+ _ finder_options: the commandline options object. This is an instance of
+ telemetry.internal.browser.browser_options.BrowserFinderOptions.
+ _ test_class_name: the name of the test class to be run.
+ _ test_cases_ids_to_run: the ids of the test cases to be run.
Ken Russell (switch to Gerrit) 2016/12/21 00:12:59 Grammar: here and throughout: test_cases_ids -> te
nednguyen 2016/12/21 20:29:04 Done.
+
+ This object is designed to be pickle-able so that it can be easily pass from
+ the main process to test subprocesses. It also supports immutable mode to
+ ensure its data won't be changed by the subprocesses.
+ """
+ def __init__(self):
+ self._finder_options = None
+ self._test_class_name = None
+ self._test_cases_ids_to_run = set()
+ self._frozen = False
+
+ def Freeze(self):
+ """ Makes the |self| object immutable.
+
+ Calling setter on |self|'s property will throw exception.
+ """
+ assert self._finder_options
+ assert self._test_class_name
+ self._frozen = True
+ self._test_cases_ids_to_run = sets.ImmutableSet(self._test_cases_ids_to_run)
+
+ @property
+ def finder_options(self):
+ return self._finder_options
+
+ @property
+ def test_class_name(self):
+ return self._test_class_name
+
+ @property
+ def test_cases_ids_to_run(self):
+ return self._test_cases_ids_to_run
+
+ @finder_options.setter
+ def finder_options(self, value):
+ assert not self._frozen
+ self._finder_options = value
+
+ @test_class_name.setter
+ def test_class_name(self, value):
+ assert not self._test_class_name
+ self._test_class_name = value

Powered by Google App Engine
This is Rietveld 408576698