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