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

Unified Diff: scripts/slave/recipe_modules/auto_bisect/test_results_cache.py

Issue 940123005: Adding ability to bisect recipe to bisect into dependency repos. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@hax
Patch Set: Addressing feedback, adding TODOs Created 5 years, 9 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
« no previous file with comments | « scripts/slave/recipe_modules/auto_bisect/revision_state.py ('k') | scripts/slave/recipes/bisect.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/auto_bisect/test_results_cache.py
diff --git a/scripts/slave/recipe_modules/auto_bisect/test_results_cache.py b/scripts/slave/recipe_modules/auto_bisect/test_results_cache.py
new file mode 100644
index 0000000000000000000000000000000000000000..b393e2a5b9153d1ad6db71cb664788ace5c9ea4b
--- /dev/null
+++ b/scripts/slave/recipe_modules/auto_bisect/test_results_cache.py
@@ -0,0 +1,53 @@
+# Copyright 2015 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.
+"""Local testing cache for test results.
+
+The purpose of these functions is for the bisector to save some state between
+runs. Specifically, it is meant to save the results of running a specific test
+on a specific revision so that further bisections requiring them do not trigger
+a new test job every time.
+"""
+
+import hashlib
+import json
+import os
+import sys
+
+resultset_file = '/tmp/bisect/test_results_cache'
+
+def make_id(*params):# pragma: no cover
+ id_string = json.dumps(params)
+ return hashlib.sha1(id_string).hexdigest()
+
+def has_results(name):# pragma: no cover
+ return name in _get_result_set()
+
+def save_results(name, value):# pragma: no cover
+ rs = _get_result_set()
+ rs[name] = value
+ _write_result_set(rs)
+
+def _get_result_set():# pragma: no cover
+ if os.path.isfile(resultset_file):
+ contents = open(resultset_file).read()
+ resultset = json.loads(contents)
+ return resultset
+ else:
+ return {}
+
+def _write_result_set(resultset): # pragma: no cover
+ _dir = os.path.dirname(resultset_file)
+ if not os.path.exists(_dir):
+ os.mkdir(_dir)
+ with open(resultset_file, 'w') as of:
+ contents = json.dumps(resultset)
+ of.write(json.dumps(resultset))
+
+def main(): # pragma: no cover
+ some_id = make_id('dummy_string')
+ if not has_results(some_id):
+ save_results(some_id, 'dummy_value')
+
+if __name__ == '__main__':
+ sys.exit(main()) # pragma: no cover
« no previous file with comments | « scripts/slave/recipe_modules/auto_bisect/revision_state.py ('k') | scripts/slave/recipes/bisect.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698