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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 for args in _iterate_over_config(configs_to_test): | 31 for args in _iterate_over_config(configs_to_test): |
32 config = Config(**args) | 32 config = Config(**args) |
33 gn_args = gn.GNArgsForConfig(config) | 33 gn_args = gn.GNArgsForConfig(config) |
34 new_config = gn.ConfigForGNArgs(gn_args) | 34 new_config = gn.ConfigForGNArgs(gn_args) |
35 self.assertDictEqual(config.values, new_config.values) | 35 self.assertDictEqual(config.values, new_config.values) |
36 | 36 |
37 def testGNToConfigToGN(self): | 37 def testGNToConfigToGN(self): |
38 """Tests that gn to config to gn is the identity""" | 38 """Tests that gn to config to gn is the identity""" |
39 configs_to_test = { | 39 configs_to_test = { |
40 "os": [None, "android", "chromeos"], | 40 "target_os": [None, "android", "chromeos"], |
41 "target_cpu": ["x86", "x64", "arm"], | 41 "target_cpu": ["x86", "x64", "arm"], |
42 "is_debug": [False, True], | 42 "is_debug": [False, True], |
43 "is_clang": [False, True], | 43 "is_clang": [False, True], |
44 "is_asan": [False, True], | 44 "is_asan": [False, True], |
45 "use_goma": [False], | 45 "use_goma": [False], |
46 "mojo_use_nacl": [False, True], | 46 "mojo_use_nacl": [False, True], |
47 "mojo_use_go": [False], | 47 "mojo_use_go": [False], |
48 "dcheck_always_on": [False, True], | 48 "dcheck_always_on": [False, True], |
49 } | 49 } |
50 | 50 |
51 for args in _iterate_over_config(configs_to_test): | 51 for args in _iterate_over_config(configs_to_test): |
52 if args.get('os', None) == "chromeos": | 52 if args.get('target_os', None) == "chromeos": |
53 args['use_glib'] = False | 53 args['use_glib'] = False |
54 args['use_system_harfbuzz'] = False | 54 args['use_system_harfbuzz'] = False |
55 if args.get('os', None) is None and sys.platform[:5] == 'linux': | 55 if args.get('target_os', None) is None and sys.platform[:5] == 'linux': |
56 args["use_aura"] = False | 56 args["use_aura"] = False |
57 args["use_glib"] = False | 57 args["use_glib"] = False |
58 args["use_system_harfbuzz"] = False | 58 args["use_system_harfbuzz"] = False |
59 config = gn.ConfigForGNArgs(args) | 59 config = gn.ConfigForGNArgs(args) |
60 new_args = gn.GNArgsForConfig(config) | 60 new_args = gn.GNArgsForConfig(config) |
61 self.assertDictEqual(args, new_args) | 61 self.assertDictEqual(args, new_args) |
62 | 62 |
63 | 63 |
64 def _iterate_over_config(config): | 64 def _iterate_over_config(config): |
65 def product_to_dict(p): | 65 def product_to_dict(p): |
66 return dict(filter(lambda x: x[1] is not None, zip(config.keys(), p))) | 66 return dict(filter(lambda x: x[1] is not None, zip(config.keys(), p))) |
67 return itertools.imap(product_to_dict, itertools.product(*config.values())) | 67 return itertools.imap(product_to_dict, itertools.product(*config.values())) |
68 | 68 |
69 | 69 |
70 if __name__ == "__main__": | 70 if __name__ == "__main__": |
71 unittest.main() | 71 unittest.main() |
OLD | NEW |