Home | History | Annotate | Download | only in mac
      1 #!/usr/bin/env python
      2 
      3 # Copyright (c) 2013 Google Inc. All rights reserved.
      4 # Use of this source code is governed by a BSD-style license that can be
      5 # found in the LICENSE file.
      6 
      7 """
      8 Verifies that xctest targets are correctly configured.
      9 """
     10 
     11 import TestGyp
     12 
     13 import sys
     14 
     15 if sys.platform == 'darwin':
     16   test = TestGyp.TestGyp(formats=['xcode'])
     17 
     18   # Ignore this test if Xcode 5 is not installed
     19   import subprocess
     20   job = subprocess.Popen(['xcodebuild', '-version'],
     21                          stdout=subprocess.PIPE,
     22                          stderr=subprocess.STDOUT)
     23   out, err = job.communicate()
     24   if job.returncode != 0:
     25     raise Exception('Error %d running xcodebuild' % job.returncode)
     26   xcode_version, build_number = out.splitlines()
     27   # Convert the version string from 'Xcode 5.0' to ['5','0'].
     28   xcode_version = xcode_version.split()[-1].split('.')
     29   if xcode_version < ['5']:
     30     test.pass_test()
     31 
     32   CHDIR = 'xctest'
     33   test.run_gyp('test.gyp', chdir=CHDIR)
     34   test.build('test.gyp', chdir=CHDIR, arguments=['-scheme', 'classes', 'test'])
     35 
     36   test.built_file_must_match('tests.xctest/Contents/Resources/resource.txt',
     37                              'foo\n', chdir=CHDIR)
     38   test.pass_test()
     39