OLD | NEW |
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. 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 """ | 5 """ |
6 TestGyp.py: a testing framework for GYP integration tests. | 6 TestGyp.py: a testing framework for GYP integration tests. |
7 """ | 7 """ |
8 | 8 |
9 import collections | 9 import collections |
10 from contextlib import contextmanager | 10 from contextlib import contextmanager |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 build_tool_list = [] | 82 build_tool_list = [] |
83 | 83 |
84 _exe = TestCommon.exe_suffix | 84 _exe = TestCommon.exe_suffix |
85 _obj = TestCommon.obj_suffix | 85 _obj = TestCommon.obj_suffix |
86 shobj_ = TestCommon.shobj_prefix | 86 shobj_ = TestCommon.shobj_prefix |
87 _shobj = TestCommon.shobj_suffix | 87 _shobj = TestCommon.shobj_suffix |
88 lib_ = TestCommon.lib_prefix | 88 lib_ = TestCommon.lib_prefix |
89 _lib = TestCommon.lib_suffix | 89 _lib = TestCommon.lib_suffix |
90 dll_ = TestCommon.dll_prefix | 90 dll_ = TestCommon.dll_prefix |
91 _dll = TestCommon.dll_suffix | 91 _dll = TestCommon.dll_suffix |
| 92 module_ = TestCommon.module_prefix |
| 93 _module = TestCommon.module_suffix |
92 | 94 |
93 # Constants to represent different targets. | 95 # Constants to represent different targets. |
94 ALL = '__all__' | 96 ALL = '__all__' |
95 DEFAULT = '__default__' | 97 DEFAULT = '__default__' |
96 | 98 |
97 # Constants for different target types. | 99 # Constants for different target types. |
98 EXECUTABLE = '__executable__' | 100 EXECUTABLE = '__executable__' |
99 STATIC_LIB = '__static_lib__' | 101 STATIC_LIB = '__static_lib__' |
100 SHARED_LIB = '__shared_lib__' | 102 SHARED_LIB = '__shared_lib__' |
| 103 LOADABLE_MODULE = '__loadable_module__' |
101 | 104 |
102 def __init__(self, gyp=None, *args, **kw): | 105 def __init__(self, gyp=None, *args, **kw): |
103 self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0])) | 106 self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0])) |
104 self.extra_args = sys.argv[1:] | 107 self.extra_args = sys.argv[1:] |
105 | 108 |
106 if not gyp: | 109 if not gyp: |
107 gyp = os.environ.get('TESTGYP_GYP') | 110 gyp = os.environ.get('TESTGYP_GYP') |
108 if not gyp: | 111 if not gyp: |
109 if sys.platform == 'win32': | 112 if sys.platform == 'win32': |
110 gyp = 'gyp.bat' | 113 gyp = 'gyp.bat' |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 A bare=True keyword argument specifies that prefixes and suffixes shouldn't | 357 A bare=True keyword argument specifies that prefixes and suffixes shouldn't |
355 be applied. | 358 be applied. |
356 """ | 359 """ |
357 if not kw.get('bare'): | 360 if not kw.get('bare'): |
358 if type == self.EXECUTABLE: | 361 if type == self.EXECUTABLE: |
359 name = name + self._exe | 362 name = name + self._exe |
360 elif type == self.STATIC_LIB: | 363 elif type == self.STATIC_LIB: |
361 name = self.lib_ + name + self._lib | 364 name = self.lib_ + name + self._lib |
362 elif type == self.SHARED_LIB: | 365 elif type == self.SHARED_LIB: |
363 name = self.dll_ + name + self._dll | 366 name = self.dll_ + name + self._dll |
| 367 elif type == self.LOADABLE_MODULE: |
| 368 name = self.module_ + name + self._module |
364 return name | 369 return name |
365 | 370 |
366 def run_built_executable(self, name, *args, **kw): | 371 def run_built_executable(self, name, *args, **kw): |
367 """ | 372 """ |
368 Runs an executable program built from a gyp-generated configuration. | 373 Runs an executable program built from a gyp-generated configuration. |
369 | 374 |
370 The specified name should be independent of any particular generator. | 375 The specified name should be independent of any particular generator. |
371 Subclasses should find the output executable in the appropriate | 376 Subclasses should find the output executable in the appropriate |
372 output build directory, tack on any necessary executable suffix, etc. | 377 output build directory, tack on any necessary executable suffix, etc. |
373 """ | 378 """ |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 | 1142 |
1138 def TestGyp(*args, **kw): | 1143 def TestGyp(*args, **kw): |
1139 """ | 1144 """ |
1140 Returns an appropriate TestGyp* instance for a specified GYP format. | 1145 Returns an appropriate TestGyp* instance for a specified GYP format. |
1141 """ | 1146 """ |
1142 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) | 1147 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) |
1143 for format_class in format_class_list: | 1148 for format_class in format_class_list: |
1144 if format == format_class.format: | 1149 if format == format_class.format: |
1145 return format_class(*args, **kw) | 1150 return format_class(*args, **kw) |
1146 raise Exception, "unknown format %r" % format | 1151 raise Exception, "unknown format %r" % format |
OLD | NEW |