Chromium Code Reviews| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 | 281 |
| 282 # TODO: --depth=. works around Chromium-specific tree climbing. | 282 # TODO: --depth=. works around Chromium-specific tree climbing. |
| 283 depth = kw.pop('depth', '.') | 283 depth = kw.pop('depth', '.') |
| 284 run_args = ['--depth='+depth] | 284 run_args = ['--depth='+depth] |
| 285 run_args.extend(['--format='+f for f in self.formats]); | 285 run_args.extend(['--format='+f for f in self.formats]); |
| 286 run_args.append(gyp_file) | 286 run_args.append(gyp_file) |
| 287 if self.no_parallel: | 287 if self.no_parallel: |
| 288 run_args += ['--no-parallel'] | 288 run_args += ['--no-parallel'] |
| 289 # TODO: if extra_args contains a '--build' flag | 289 # TODO: if extra_args contains a '--build' flag |
| 290 # we really want that to only apply to the last format (self.format). | 290 # we really want that to only apply to the last format (self.format). |
| 291 run_args.extend(self.extra_args) | 291 run_args.extend(self.extra_args) |
|
sdefresne
2014/09/02 15:13:05
I don't really like the fact that you add to chang
Tobias
2014/10/02 18:19:19
I share your feelings, I also feel a bit uneasy ab
| |
| 292 run_args.extend(args) | 292 run_args.extend(args) |
| 293 return self.run(program=self.gyp, arguments=run_args, **kw) | 293 return self.run(program=self.gyp, arguments=run_args, **kw) |
| 294 | 294 |
| 295 def run(self, *args, **kw): | 295 def run(self, *args, **kw): |
| 296 """ | 296 """ |
| 297 Executes a program by calling the superclass .run() method. | 297 Executes a program by calling the superclass .run() method. |
| 298 | 298 |
| 299 This exists to provide a common place to filter out keyword | 299 This exists to provide a common place to filter out keyword |
| 300 arguments implemented in this layer, without having to update | 300 arguments implemented in this layer, without having to update |
| 301 the tool-specific subclasses or clutter the tests themselves | 301 the tool-specific subclasses or clutter the tests themselves |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1318 result = [] | 1318 result = [] |
| 1319 chdir = kw.get('chdir') | 1319 chdir = kw.get('chdir') |
| 1320 if chdir: | 1320 if chdir: |
| 1321 result.append(chdir) | 1321 result.append(chdir) |
| 1322 configuration = self.configuration_dirname() | 1322 configuration = self.configuration_dirname() |
| 1323 result.extend(['build', configuration]) | 1323 result.extend(['build', configuration]) |
| 1324 result.append(self.built_file_basename(name, type, **kw)) | 1324 result.append(self.built_file_basename(name, type, **kw)) |
| 1325 return self.workpath(*result) | 1325 return self.workpath(*result) |
| 1326 | 1326 |
| 1327 | 1327 |
| 1328 class TestGypXcodeNinja(TestGypXcode): | |
| 1329 """ | |
| 1330 Subclass for testing the GYP Xcode Ninja generator. | |
| 1331 """ | |
| 1332 format = 'xcode-ninja' | |
| 1333 | |
| 1334 def initialize_build_tool(self): | |
| 1335 super(TestGypXcodeNinja, self).initialize_build_tool() | |
| 1336 # When using '--build', make sure ninja is first in the format list. | |
| 1337 self.formats.insert(0, 'ninja') | |
| 1338 | |
| 1339 def build(self, gyp_file, target=None, **kw): | |
| 1340 """ | |
| 1341 Runs an xcodebuild using the .xcodeproj generated from the specified | |
| 1342 gyp_file. | |
| 1343 """ | |
| 1344 build_config = self.configuration | |
| 1345 if build_config and build_config.endswith(('-iphoneos', | |
| 1346 '-iphonesimulator')): | |
| 1347 build_config, sdk = self.configuration.split('-') | |
| 1348 kw['arguments'] = kw.get('arguments', []) + ['-sdk', sdk] | |
| 1349 | |
| 1350 with self._build_configuration(build_config): | |
| 1351 return super(TestGypXcodeNinja, self).build( | |
| 1352 gyp_file.replace('.gyp', '.ninja.gyp'), target, **kw) | |
| 1353 | |
| 1354 @contextmanager | |
| 1355 def _build_configuration(self, build_config): | |
| 1356 config = self.configuration | |
| 1357 self.configuration = build_config | |
| 1358 try: | |
| 1359 yield | |
| 1360 finally: | |
| 1361 self.configuration = config | |
| 1362 | |
| 1363 def built_file_path(self, name, type=None, **kw): | |
| 1364 result = [] | |
| 1365 chdir = kw.get('chdir') | |
| 1366 if chdir: | |
| 1367 result.append(chdir) | |
| 1368 result.append('out') | |
| 1369 result.append(self.configuration_dirname()) | |
| 1370 subdir = kw.get('subdir') | |
| 1371 if subdir and type != self.SHARED_LIB: | |
| 1372 result.append(subdir) | |
| 1373 result.append(self.built_file_basename(name, type, **kw)) | |
| 1374 return self.workpath(*result) | |
| 1375 | |
| 1376 def up_to_date(self, gyp_file, target=None, **kw): | |
| 1377 result = self.build(gyp_file, target, **kw) | |
| 1378 if not result: | |
| 1379 stdout = self.stdout() | |
| 1380 if 'ninja: no work to do' not in stdout: | |
| 1381 self.report_not_up_to_date() | |
| 1382 self.fail_test() | |
| 1383 return result | |
| 1384 | |
| 1385 def run_built_executable(self, name, *args, **kw): | |
| 1386 """ | |
| 1387 Runs an executable built by xcodebuild + ninja. | |
| 1388 """ | |
| 1389 configuration = self.configuration_dirname() | |
| 1390 os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration) | |
| 1391 # Enclosing the name in a list avoids prepending the original dir. | |
| 1392 program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] | |
| 1393 return self.run(program=program, *args, **kw) | |
| 1394 | |
| 1395 | |
| 1328 format_class_list = [ | 1396 format_class_list = [ |
| 1329 TestGypGypd, | 1397 TestGypGypd, |
| 1330 TestGypAndroid, | 1398 TestGypAndroid, |
| 1331 TestGypCMake, | 1399 TestGypCMake, |
| 1332 TestGypMake, | 1400 TestGypMake, |
| 1333 TestGypMSVS, | 1401 TestGypMSVS, |
| 1334 TestGypMSVSNinja, | 1402 TestGypMSVSNinja, |
| 1335 TestGypNinja, | 1403 TestGypNinja, |
| 1336 TestGypXcode, | 1404 TestGypXcode, |
| 1405 TestGypXcodeNinja, | |
| 1337 ] | 1406 ] |
| 1338 | 1407 |
| 1339 def TestGyp(*args, **kw): | 1408 def TestGyp(*args, **kw): |
| 1340 """ | 1409 """ |
| 1341 Returns an appropriate TestGyp* instance for a specified GYP format. | 1410 Returns an appropriate TestGyp* instance for a specified GYP format. |
| 1342 """ | 1411 """ |
| 1343 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) | 1412 format = kw.pop('format', os.environ.get('TESTGYP_FORMAT')) |
| 1344 for format_class in format_class_list: | 1413 for format_class in format_class_list: |
| 1345 if format == format_class.format: | 1414 if format == format_class.format: |
| 1346 return format_class(*args, **kw) | 1415 return format_class(*args, **kw) |
| 1347 raise Exception, "unknown format %r" % format | 1416 raise Exception, "unknown format %r" % format |
| OLD | NEW |