Home | History | Annotate | Download | only in mac
      1 #!/usr/bin/env python
      2 
      3 # Copyright (c) 2012 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 app bundles are built correctly.
      9 """
     10 
     11 import TestGyp
     12 
     13 import os
     14 import sys
     15 
     16 if sys.platform == 'darwin':
     17   print "This test is currently disabled: https://crbug.com/483696."
     18   sys.exit(0)
     19 
     20 
     21 def ls(path):
     22   '''Returns a list of all files in a directory, relative to the directory.'''
     23   result = []
     24   for dirpath, _, files in os.walk(path):
     25     for f in files:
     26       result.append(os.path.join(dirpath, f)[len(path) + 1:])
     27   return result
     28 
     29 
     30 if sys.platform == 'darwin':
     31   test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
     32 
     33   test.run_gyp('framework.gyp', chdir='framework')
     34 
     35   test.build('framework.gyp', 'test_framework', chdir='framework')
     36 
     37   # Binary
     38   test.built_file_must_exist(
     39       'Test Framework.framework/Versions/A/Test Framework',
     40       chdir='framework')
     41 
     42   # Info.plist
     43   info_plist = test.built_file_path(
     44       'Test Framework.framework/Versions/A/Resources/Info.plist',
     45       chdir='framework')
     46   test.must_exist(info_plist)
     47   test.must_contain(info_plist, 'com.yourcompany.Test_Framework')
     48 
     49   # Resources
     50   test.built_file_must_exist(
     51       'Test Framework.framework/Versions/A/Resources/English.lproj/'
     52       'InfoPlist.strings',
     53       chdir='framework')
     54 
     55   # Symlinks created by packaging process
     56   test.built_file_must_exist('Test Framework.framework/Versions/Current',
     57                              chdir='framework')
     58   test.built_file_must_exist('Test Framework.framework/Resources',
     59                              chdir='framework')
     60   test.built_file_must_exist('Test Framework.framework/Test Framework',
     61                              chdir='framework')
     62   # PkgInfo.
     63   test.built_file_must_not_exist(
     64       'Test Framework.framework/Versions/A/Resources/PkgInfo',
     65       chdir='framework')
     66 
     67   # Check that no other files get added to the bundle.
     68   if set(ls(test.built_file_path('Test Framework.framework',
     69                                  chdir='framework'))) != \
     70      set(['Versions/A/Test Framework',
     71           'Versions/A/Resources/Info.plist',
     72           'Versions/A/Resources/English.lproj/InfoPlist.strings',
     73           'Test Framework',
     74           'Versions/A/Libraries/empty.c',  # Written by a gyp action.
     75           ]):
     76     test.fail_test()
     77 
     78   test.pass_test()
     79