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 GC objc settings are handled correctly. 9""" 10 11import TestGyp 12import TestMac 13 14import sys 15 16if sys.platform == 'darwin': 17 # set |match| to ignore build stderr output. 18 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'], 19 match = lambda a, b: True) 20 21 # Xcode 5.1 removed support for garbage-collection: 22 # error: garbage collection is no longer supported 23 if TestMac.Xcode.Version() < '0510': 24 25 CHDIR = 'objc-gc' 26 test.run_gyp('test.gyp', chdir=CHDIR) 27 28 build_error_code = { 29 'xcode': [1, 65], # 1 for xcode 3, 65 for xcode 4 (see `man sysexits`) 30 'make': 2, 31 'ninja': 1, 32 }[test.format] 33 34 test.build('test.gyp', 'gc_exe_fails', chdir=CHDIR, status=build_error_code) 35 test.build( 36 'test.gyp', 'gc_off_exe_req_lib', chdir=CHDIR, status=build_error_code) 37 38 test.build('test.gyp', 'gc_req_exe', chdir=CHDIR) 39 test.run_built_executable('gc_req_exe', chdir=CHDIR, stdout="gc on: 1\n") 40 41 test.build('test.gyp', 'gc_exe_req_lib', chdir=CHDIR) 42 test.run_built_executable( 43 'gc_exe_req_lib', chdir=CHDIR, stdout="gc on: 1\n") 44 45 test.build('test.gyp', 'gc_exe', chdir=CHDIR) 46 test.run_built_executable('gc_exe', chdir=CHDIR, stdout="gc on: 1\n") 47 48 test.build('test.gyp', 'gc_off_exe', chdir=CHDIR) 49 test.run_built_executable('gc_off_exe', chdir=CHDIR, stdout="gc on: 0\n") 50 51 test.pass_test() 52