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', chdir=CHDIR) |
| 22 |
22 test.build('test.gyp', test.ALL, chdir=CHDIR) | 23 test.build('test.gyp', test.ALL, chdir=CHDIR) |
23 | 24 |
24 # Binary. | 25 # Binary. |
25 binary = test.built_file_path( | 26 binary = test.built_file_path( |
26 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', | 27 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', |
27 chdir=CHDIR) | 28 chdir=CHDIR) |
28 test.must_exist(binary) | 29 test.must_exist(binary) |
29 MH_BUNDLE = 8 | 30 MH_BUNDLE = 8 |
30 if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE: | 31 if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE: |
31 test.fail_test() | 32 test.fail_test() |
32 | 33 |
33 # Info.plist. | 34 # Info.plist. |
34 info_plist = test.built_file_path( | 35 info_plist = test.built_file_path( |
35 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) | 36 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) |
36 test.must_exist(info_plist) | 37 test.must_exist(info_plist) |
37 test.must_contain(info_plist, """ | 38 test.must_contain(info_plist, """ |
38 <key>CFBundleExecutable</key> | 39 <key>CFBundleExecutable</key> |
39 <string>test_loadable_module</string> | 40 <string>test_loadable_module</string> |
40 """) | 41 """) |
41 | 42 |
42 # PkgInfo. | 43 # PkgInfo. |
43 test.built_file_must_not_exist( | 44 test.built_file_must_not_exist( |
44 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) | 45 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) |
45 test.built_file_must_not_exist( | 46 test.built_file_must_not_exist( |
46 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) | 47 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) |
47 | 48 |
48 test.pass_test() | 49 test.pass_test() |
OLD | NEW |