| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """ | 7 """ |
| 8 Tests that a loadable_module target is built correctly. | 8 Tests that a loadable_module target is built correctly. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import TestGyp | 11 import TestGyp |
| 12 | 12 |
| 13 import os | 13 import os |
| 14 import struct | 14 import struct |
| 15 import sys | 15 import sys |
| 16 | 16 |
| 17 if sys.platform == 'darwin': | 17 if sys.platform == 'darwin': |
| 18 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | 18 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
| 19 | 19 |
| 20 CHDIR = 'loadable-module' | 20 CHDIR = 'loadable-module' |
| 21 test.run_gyp('test.gyp', chdir=CHDIR) | 21 test.run_gyp('test.gyp', |
| 22 '-G', 'xcode_ninja_target_pattern=^.*$', |
| 23 chdir=CHDIR) |
| 24 |
| 22 test.build('test.gyp', test.ALL, chdir=CHDIR) | 25 test.build('test.gyp', test.ALL, chdir=CHDIR) |
| 23 | 26 |
| 24 # Binary. | 27 # Binary. |
| 25 binary = test.built_file_path( | 28 binary = test.built_file_path( |
| 26 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', | 29 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', |
| 27 chdir=CHDIR) | 30 chdir=CHDIR) |
| 28 test.must_exist(binary) | 31 test.must_exist(binary) |
| 29 MH_BUNDLE = 8 | 32 MH_BUNDLE = 8 |
| 30 if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE: | 33 if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE: |
| 31 test.fail_test() | 34 test.fail_test() |
| 32 | 35 |
| 33 # Info.plist. | 36 # Info.plist. |
| 34 info_plist = test.built_file_path( | 37 info_plist = test.built_file_path( |
| 35 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) | 38 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) |
| 36 test.must_exist(info_plist) | 39 test.must_exist(info_plist) |
| 37 test.must_contain(info_plist, """ | 40 test.must_contain(info_plist, """ |
| 38 <key>CFBundleExecutable</key> | 41 <key>CFBundleExecutable</key> |
| 39 <string>test_loadable_module</string> | 42 <string>test_loadable_module</string> |
| 40 """) | 43 """) |
| 41 | 44 |
| 42 # PkgInfo. | 45 # PkgInfo. |
| 43 test.built_file_must_not_exist( | 46 test.built_file_must_not_exist( |
| 44 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) | 47 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) |
| 45 test.built_file_must_not_exist( | 48 test.built_file_must_not_exist( |
| 46 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) | 49 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) |
| 47 | 50 |
| 48 test.pass_test() | 51 test.pass_test() |
| OLD | NEW |