Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: test/lib/TestGyp.py

Issue 421453003: Add TestGypXcodeNinja to run tests against the xcode-ninja generator (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase onto origin/master Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/lib/TestGyp.py
diff --git a/test/lib/TestGyp.py b/test/lib/TestGyp.py
index ff954189da93048ef6964d3d44d840a8dfa37686..04e773dff42b3abe6acff5cf8a2a45eff0e9053c 100644
--- a/test/lib/TestGyp.py
+++ b/test/lib/TestGyp.py
@@ -1325,6 +1325,74 @@ class TestGypXcode(TestGypBase):
return self.workpath(*result)
+class TestGypXcodeNinja(TestGypXcode):
+ """
+ Subclass for testing the GYP Xcode Ninja generator.
+ """
+ format = 'xcode-ninja'
+
+ def initialize_build_tool(self):
+ super(TestGypXcodeNinja, self).initialize_build_tool()
+ # When using '--build', make sure ninja is first in the format list.
+ self.formats.insert(0, 'ninja')
+
+ def build(self, gyp_file, target=None, **kw):
+ """
+ Runs an xcodebuild using the .xcodeproj generated from the specified
+ gyp_file.
+ """
+ build_config = self.configuration
+ if build_config and build_config.endswith(('-iphoneos',
+ '-iphonesimulator')):
+ build_config, sdk = self.configuration.split('-')
+ kw['arguments'] = kw.get('arguments', []) + ['-sdk', sdk]
+
+ with self._build_configuration(build_config):
+ return super(TestGypXcodeNinja, self).build(
+ gyp_file.replace('.gyp', '.ninja.gyp'), target, **kw)
+
+ @contextmanager
+ def _build_configuration(self, build_config):
+ config = self.configuration
+ self.configuration = build_config
+ try:
+ yield
+ finally:
+ self.configuration = config
+
+ def built_file_path(self, name, type=None, **kw):
+ result = []
+ chdir = kw.get('chdir')
+ if chdir:
+ result.append(chdir)
+ result.append('out')
+ result.append(self.configuration_dirname())
+ subdir = kw.get('subdir')
+ if subdir and type != self.SHARED_LIB:
+ result.append(subdir)
+ result.append(self.built_file_basename(name, type, **kw))
+ return self.workpath(*result)
+
+ def up_to_date(self, gyp_file, target=None, **kw):
+ result = self.build(gyp_file, target, **kw)
+ if not result:
+ stdout = self.stdout()
+ if 'ninja: no work to do' not in stdout:
+ self.report_not_up_to_date()
+ self.fail_test()
+ return result
+
+ def run_built_executable(self, name, *args, **kw):
+ """
+ Runs an executable built by xcodebuild + ninja.
+ """
+ configuration = self.configuration_dirname()
+ os.environ['DYLD_LIBRARY_PATH'] = os.path.join('out', configuration)
+ # Enclosing the name in a list avoids prepending the original dir.
+ program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)]
+ return self.run(program=program, *args, **kw)
+
+
format_class_list = [
TestGypGypd,
TestGypAndroid,
@@ -1334,6 +1402,7 @@ format_class_list = [
TestGypMSVSNinja,
TestGypNinja,
TestGypXcode,
+ TestGypXcodeNinja,
]
def TestGyp(*args, **kw):

Powered by Google App Engine
This is Rietveld 408576698