| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import itertools | 5 import itertools |
| 6 import sys | 6 import sys |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 import mopy.gn as gn | 9 import mopy.gn as gn |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 "target_cpu": [None, "x86", "x64", "arm", "arm64"], | 21 "target_cpu": [None, "x86", "x64", "arm", "arm64"], |
| 22 "is_simulator": [False, True], | 22 "is_simulator": [False, True], |
| 23 "is_debug": [False, True], | 23 "is_debug": [False, True], |
| 24 "is_official_build": [False, True], | 24 "is_official_build": [False, True], |
| 25 "is_clang": [False, True], | 25 "is_clang": [False, True], |
| 26 "sanitizer": [None, Config.SANITIZER_ASAN], | 26 "sanitizer": [None, Config.SANITIZER_ASAN], |
| 27 "use_goma": [False], | 27 "use_goma": [False], |
| 28 "use_nacl": [False, True], | 28 "use_nacl": [False, True], |
| 29 "mojo_use_go": [False], | 29 "mojo_use_go": [False], |
| 30 "dcheck_always_on": [False, True], | 30 "dcheck_always_on": [False, True], |
| 31 "boringssl_path": [""], |
| 31 } | 32 } |
| 32 if sys.platform == "darwin": | 33 if sys.platform == "darwin": |
| 33 configs_to_test["target_os"].remove("linux") | 34 configs_to_test["target_os"].remove("linux") |
| 34 | 35 |
| 35 for args in _iterate_over_config(configs_to_test): | 36 for args in _iterate_over_config(configs_to_test): |
| 36 if args.get("target_os") != "ios" and args["is_simulator"]: | 37 if args.get("target_os") != "ios" and args["is_simulator"]: |
| 37 continue | 38 continue |
| 38 config = Config(**args) | 39 config = Config(**args) |
| 39 gn_args = gn.GNArgsForConfig(config) | 40 gn_args = gn.GNArgsForConfig(config) |
| 40 new_config = gn.ConfigForGNArgs(gn_args) | 41 new_config = gn.ConfigForGNArgs(gn_args) |
| 41 self.assertDictEqual(config.values, new_config.values) | 42 self.assertDictEqual(config.values, new_config.values) |
| 42 | 43 |
| 43 def testGNToConfigToGN(self): | 44 def testGNToConfigToGN(self): |
| 44 """Tests that gn to config to gn is the identity""" | 45 """Tests that gn to config to gn is the identity""" |
| 45 # TODO(vtl): Test OSes other than None (== host?) and "android". | 46 # TODO(vtl): Test OSes other than None (== host?) and "android". |
| 46 configs_to_test = { | 47 configs_to_test = { |
| 47 "target_os": [None, "android"], | 48 "target_os": [None, "android"], |
| 48 "target_cpu": ["x86", "x64", "arm", "arm64"], | 49 "target_cpu": ["x86", "x64", "arm", "arm64"], |
| 49 "is_debug": [False, True], | 50 "is_debug": [False, True], |
| 50 "is_official_build": [False, True], | 51 "is_official_build": [False, True], |
| 51 "is_clang": [False, True], | 52 "is_clang": [False, True], |
| 52 "is_asan": [False, True], | 53 "is_asan": [False, True], |
| 53 "use_goma": [False], | 54 "use_goma": [False], |
| 54 "mojo_use_nacl": [False, True], | 55 "mojo_use_nacl": [False, True], |
| 55 "mojo_use_go": [False], | 56 "mojo_use_go": [False], |
| 56 "dcheck_always_on": [False, True], | 57 "dcheck_always_on": [False, True], |
| 58 "dart_boringssl_path": [""], |
| 57 } | 59 } |
| 58 | 60 |
| 59 for args in _iterate_over_config(configs_to_test): | 61 for args in _iterate_over_config(configs_to_test): |
| 60 config = gn.ConfigForGNArgs(args) | 62 config = gn.ConfigForGNArgs(args) |
| 61 new_args = gn.GNArgsForConfig(config) | 63 new_args = gn.GNArgsForConfig(config) |
| 62 self.assertDictEqual(args, new_args) | 64 self.assertDictEqual(args, new_args) |
| 63 | 65 |
| 64 | 66 |
| 65 def _iterate_over_config(config): | 67 def _iterate_over_config(config): |
| 66 def product_to_dict(p): | 68 def product_to_dict(p): |
| 67 return dict(filter(lambda x: x[1] is not None, zip(config.keys(), p))) | 69 return dict(filter(lambda x: x[1] is not None, zip(config.keys(), p))) |
| 68 return itertools.imap(product_to_dict, itertools.product(*config.values())) | 70 return itertools.imap(product_to_dict, itertools.product(*config.values())) |
| 69 | 71 |
| 70 | 72 |
| 71 if __name__ == "__main__": | 73 if __name__ == "__main__": |
| 72 unittest.main() | 74 unittest.main() |
| OLD | NEW |