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

Unified Diff: tools/tests/factory_configuration/verify_mapping.py

Issue 14517004: Change Builder Names, MkIII (Closed) Base URL: http://skia.googlecode.com/svn/buildbot/
Patch Set: Created 7 years, 8 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: tools/tests/factory_configuration/verify_mapping.py
===================================================================
--- tools/tests/factory_configuration/verify_mapping.py (revision 0)
+++ tools/tests/factory_configuration/verify_mapping.py (revision 0)
@@ -0,0 +1,61 @@
+# Copyright (c) 2013 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.
+
+""" Runs a series of tests on a file which maps old builder names to new builder
+names. """
+
+
+import json
+import os
+import sys
+
+
+EXPECTED_DIR = os.path.join(os.path.dirname(__file__), 'expected')
+
+
+def VerifyMapping(old_name, new_name, slaves_cfg, mapping):
+ """ Run assertions to verify that the mapping from an old builder name to a
+ new builder name is valid. """
+ try:
+ # First, is the old name actually a builder name?
+ assert os.path.isfile(os.path.join(EXPECTED_DIR, old_name))
+
+ # Trybots should maintain the trybot suffix.
+ if old_name.endswith('Trybot'):
+ assert new_name.endswith('Trybot')
+ else:
+ # If the builder isn't a trybot, it should be explicitly listed in
+ # slaves.cfg.
+ assert new_name in slaves_cfg
+
+ # Assert that the new builder name isn't duplicated.
+ match_count = 0
+ for val in mapping.itervalues():
+ if val == new_name:
+ match_count += 1
+ assert match_count == 1
+
+ # ADD YOUR ASSERTIONS HERE
+
+ except Exception:
+ print 'Failed assertion for (%s to %s)' % (old_name, new_name)
+ raise
+
+
+def main(argv):
+ if len(argv) != 2:
+ raise Exception('Invalid arguments given; you must provide a mapping file.')
+ with open(argv[1]) as f:
+ mapping = json.load(f)
+
+ slaves_cfg_file = os.path.join('master', 'slaves.cfg')
+ with open(slaves_cfg_file) as f:
+ slaves_cfg = f.read()
+
+ for old_name, new_name in mapping.iteritems():
+ VerifyMapping(old_name, new_name, slaves_cfg, mapping)
+
+
+if '__main__' == __name__:
+ sys.exit(main(sys.argv))
« master/skia_master_scripts/factory.py ('K') | « tools/tests/factory_configuration/rename_builders.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698