| OLD | NEW |
| (Empty) |
| 1 # Copyright 2014 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 import itertools | |
| 6 import sys | |
| 7 import unittest | |
| 8 | |
| 9 import mopy.gn as gn | |
| 10 | |
| 11 from mopy.config import Config | |
| 12 | |
| 13 | |
| 14 class GTestListTestsTest(unittest.TestCase): | |
| 15 """Tests mopy.gn.""" | |
| 16 | |
| 17 def testConfigToGNToConfig(self): | |
| 18 """Tests that config to gn to config is the identity""" | |
| 19 configs_to_test = { | |
| 20 "target_os": [None, "android", "chromeos", "linux"], | |
| 21 "target_arch": [None, "x86", "x64", "arm"], | |
| 22 "is_debug": [False, True], | |
| 23 "is_clang": [False, True], | |
| 24 "sanitizer": [None, Config.SANITIZER_ASAN], | |
| 25 "use_goma": [False], | |
| 26 "use_nacl": [False, True], | |
| 27 } | |
| 28 | |
| 29 for args in _iterate_over_config(configs_to_test): | |
| 30 config = Config(**args) | |
| 31 gn_args = gn.GNArgsForConfig(config) | |
| 32 new_config = gn.ConfigForGNArgs(gn_args) | |
| 33 self.assertDictEqual(config.values, new_config.values) | |
| 34 | |
| 35 def testGNToConfigToGN(self): | |
| 36 """Tests that gn to config to gn is the identity""" | |
| 37 configs_to_test = { | |
| 38 "os": [None, "android", "chromeos"], | |
| 39 "cpu_arch": ["x86", "x64", "arm"], | |
| 40 "is_debug": [False, True], | |
| 41 "is_clang": [False, True], | |
| 42 "is_asan": [False, True], | |
| 43 "use_goma": [False], | |
| 44 "mojo_use_nacl": [False, True], | |
| 45 } | |
| 46 | |
| 47 for args in _iterate_over_config(configs_to_test): | |
| 48 if args.get('os', None) == "chromeos": | |
| 49 args['use_glib'] = False | |
| 50 args['use_system_harfbuzz'] = False | |
| 51 if args.get('os', None) is None and sys.platform[:5] == 'linux': | |
| 52 args["is_desktop_linux"] = False | |
| 53 args["use_aura"] = False | |
| 54 args["use_glib"] = False | |
| 55 args["use_system_harfbuzz"] = False | |
| 56 config = gn.ConfigForGNArgs(args) | |
| 57 new_args = gn.GNArgsForConfig(config) | |
| 58 self.assertDictEqual(args, new_args) | |
| 59 | |
| 60 | |
| 61 def _iterate_over_config(config): | |
| 62 def product_to_dict(p): | |
| 63 return dict(filter(lambda x: x[1] is not None, zip(config.keys(), p))) | |
| 64 return itertools.imap(product_to_dict, itertools.product(*config.values())) | |
| 65 | |
| 66 | |
| 67 if __name__ == "__main__": | |
| 68 unittest.main() | |
| OLD | NEW |