Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 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 | Tests that a loadable_module target is built correctly. |
| 9 | """ |
| 10 | |
| 11 | import TestGyp |
| 12 | |
| 13 | import os |
| 14 | import struct |
| 15 | import sys |
| 16 | |
| 17 | if sys.platform == 'darwin': |
| 18 | print "This test is currently disabled: https://crbug.com/483696." |
| 19 | sys.exit(0) |
| 20 | |
| 21 | test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
| 22 | |
| 23 | CHDIR = 'loadable-module' |
| 24 | test.run_gyp('test.gyp', chdir=CHDIR) |
| 25 | |
| 26 | test.build('test.gyp', test.ALL, chdir=CHDIR) |
| 27 | |
| 28 | # Binary. |
| 29 | binary = test.built_file_path( |
| 30 | 'test_loadable_module.plugin/Contents/MacOS/test_loadable_module', |
| 31 | chdir=CHDIR) |
| 32 | test.must_exist(binary) |
| 33 | MH_BUNDLE = 8 |
| 34 | if struct.unpack('4I', open(binary, 'rb').read(16))[3] != MH_BUNDLE: |
| 35 | test.fail_test() |
| 36 | |
| 37 | # Info.plist. |
| 38 | info_plist = test.built_file_path( |
| 39 | 'test_loadable_module.plugin/Contents/Info.plist', chdir=CHDIR) |
| 40 | test.must_exist(info_plist) |
| 41 | test.must_contain(info_plist, """ |
| 42 | <key>CFBundleExecutable</key> |
| 43 | <string>test_loadable_module</string> |
| 44 | """) |
| 45 | |
| 46 | # PkgInfo. |
| 47 | test.built_file_must_not_exist( |
| 48 | 'test_loadable_module.plugin/Contents/PkgInfo', chdir=CHDIR) |
| 49 | test.built_file_must_not_exist( |
| 50 | 'test_loadable_module.plugin/Contents/Resources', chdir=CHDIR) |
| 51 | |
| 52 | test.pass_test() |