| OLD | NEW |
| (Empty) | |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """ Runs a series of tests on a mapping file. """ |
| 6 |
| 7 |
| 8 import json |
| 9 import os |
| 10 import sys |
| 11 |
| 12 |
| 13 EXPECTED_DIR = os.path.join(os.path.dirname(__file__), 'expected') |
| 14 |
| 15 |
| 16 def VerifyMapping(old_name, new_name, slaves_cfg, mapping): |
| 17 try: |
| 18 assert os.path.isfile(os.path.join(EXPECTED_DIR, old_name)) |
| 19 if old_name.endswith('Trybot'): |
| 20 assert new_name.endswith('Trybot') |
| 21 else: |
| 22 assert new_name in slaves_cfg |
| 23 |
| 24 # Assert no duplicate values |
| 25 match_count = 0 |
| 26 for val in mapping.itervalues(): |
| 27 if val == new_name: |
| 28 match_count += 1 |
| 29 assert match_count == 1 |
| 30 |
| 31 # ADD YOUR ASSERTIONS HERE |
| 32 |
| 33 except Exception: |
| 34 print 'Failed assertion for (%s to %s)' % (old_name, new_name) |
| 35 raise |
| 36 |
| 37 |
| 38 def main(argv): |
| 39 if len(argv) != 2: |
| 40 raise Exception('Invalid arguments given; you must provide a mapping file.') |
| 41 with open(argv[1]) as f: |
| 42 mapping = json.load(f) |
| 43 |
| 44 slaves_cfg_file = os.path.join('master', 'slaves.cfg') |
| 45 with open(slaves_cfg_file) as f: |
| 46 slaves_cfg = f.read() |
| 47 |
| 48 for old_name, new_name in mapping.iteritems(): |
| 49 VerifyMapping(old_name, new_name, slaves_cfg, mapping) |
| 50 |
| 51 |
| 52 if '__main__' == __name__: |
| 53 sys.exit(main(sys.argv)) |
| OLD | NEW |