Index: components/test/data/password_manager/automated_tests/run_tests.py |
diff --git a/components/test/data/password_manager/automated_tests/run_tests.py b/components/test/data/password_manager/automated_tests/run_tests.py |
index 2c0b799dc330300875d528236b6989b916257857..48a9ebf762edbeff5712407cde9bbc0972bf26c3 100644 |
--- a/components/test/data/password_manager/automated_tests/run_tests.py |
+++ b/components/test/data/password_manager/automated_tests/run_tests.py |
@@ -13,11 +13,14 @@ of the following structure: |
chrome-path=<chrome binary path> |
chromedriver-path=<chrome driver path> |
[run_options] |
+ # |write_to_sheet| is optional, the default value is false. |
write_to_sheet=[false|true] |
- tests_in_parrallel=<number of parallel tests> |
+ # |tests_in_parallel| is optional, the default value is 1. |
+ tests_in_parallel=<number of parallel tests> |
# |tests_to_runs| field is optional, if it is absent all tests will be run. |
tests_to_run=<test names to run, comma delimited> |
[output] |
+ # |save-path| is optional, the default value is /dev/null. |
save-path=<file where to save result> |
[sheet_info] |
# This section is required only when write_to_sheet=true |
@@ -177,14 +180,39 @@ class TestRunner(object): |
print "Run of test %s started" % self.test_name |
self.runner_process = subprocess.Popen(self.test_cmd) |
+def _apply_defaults(config, defaults): |
+ """Adds default values from |defaults| to |config|. |
+ |
+ Note: This differs from ConfigParser's mechanism for providing defaults in |
+ two points: |
engedy
2015/03/04 13:20:31
nit: s/points/aspects/
vabr (Chromium)
2015/03/04 13:25:34
Done.
|
+ * The "defaults" here become explicit, and are associated with sections. |
+ * Sections get created for the added defaults where needed, they need not |
engedy
2015/03/04 13:20:31
nit: ..., that is, if
vabr (Chromium)
2015/03/04 13:25:34
Done.
|
+ exist before. |
+ |
+ Args: |
+ config: A ConfigParser instance to be updated |
+ defaults: A dictionary with keys (section_string, option_string) and |
engedy
2015/03/04 13:20:30
Phrasing suggestion: A dictionary mapping (section
vabr (Chromium)
2015/03/04 13:25:34
Done.
|
+ string values. For every section/option combination not already |
+ contained in |config|, the value from |defaults| is stored in |config|. |
+ """ |
+ for (section, option) in defaults: |
+ if not config.has_section(section): |
+ config.add_section(section) |
+ if not config.has_option(section, option): |
+ config.set(section, option, defaults[(section, option)]) |
+ |
def run_tests(config_path): |
""" Runs automated tests. """ |
environment = Environment("", "", "", None, False) |
tests.Tests(environment) |
+ defaults = { ("output", "save-path"): "/dev/null", |
+ ("run_options", "tests_in_parallel"): "1", |
+ ("run_options", "write_to_sheet"): "false" } |
config = ConfigParser.ConfigParser() |
+ _apply_defaults(config, defaults) |
config.read(config_path) |
date = datetime.now().strftime('%Y-%m-%dT%H:%M:%S') |
- max_tests_in_parrallel = config.getint("run_options", "tests_in_parrallel") |
+ max_tests_in_parallel = config.getint("run_options", "tests_in_parallel") |
sheet_writer = SheetWriter(config) |
full_path = os.path.realpath(__file__) |
tests_dir = os.path.dirname(full_path) |
@@ -214,7 +242,7 @@ def run_tests(config_path): |
del runners[i] |
else: |
i += 1 |
- while len(runners) < max_tests_in_parrallel and len(tests_to_run) > 0: |
+ while len(runners) < max_tests_in_parallel and len(tests_to_run) > 0: |
runners.append(TestRunner(general_test_cmd, tests_to_run.pop())) |
time.sleep(1) # Let us wait for worker process to finish. |