OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2013 Google Inc. All rights reserved. | 3 # Copyright (c) 2013 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 Verifies things related to bundle resources. | 8 Verifies things related to bundle resources. |
9 """ | 9 """ |
10 | 10 |
11 import TestGyp | 11 import TestGyp |
12 | 12 |
| 13 import os |
| 14 import stat |
13 import sys | 15 import sys |
14 | 16 |
| 17 |
| 18 def check_attribs(path, expected_exec_bit): |
| 19 out_path = test.built_file_path( |
| 20 os.path.join('resource.app/Contents/Resources', path), chdir=CHDIR) |
| 21 |
| 22 in_stat = os.stat(os.path.join(CHDIR, path)) |
| 23 out_stat = os.stat(out_path) |
| 24 if in_stat.st_mode != out_stat.st_mode: |
| 25 test.fail_test() |
| 26 if in_stat.st_mtime == out_stat.st_mtime: |
| 27 test.fail_test() |
| 28 if out_stat.st_mode & stat.S_IXUSR != expected_exec_bit: |
| 29 test.fail_test() |
| 30 |
| 31 |
15 if sys.platform == 'darwin': | 32 if sys.platform == 'darwin': |
16 # set |match| to ignore build stderr output. | 33 # set |match| to ignore build stderr output. |
17 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | 34 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
18 | 35 |
19 CHDIR = 'bundle-resources' | 36 CHDIR = 'bundle-resources' |
20 test.run_gyp('test.gyp', chdir=CHDIR) | 37 test.run_gyp('test.gyp', chdir=CHDIR) |
21 | 38 |
22 test.build('test.gyp', test.ALL, chdir=CHDIR) | 39 test.build('test.gyp', test.ALL, chdir=CHDIR) |
23 | 40 |
24 test.built_file_must_match('resource.app/Contents/Resources/secret.txt', | 41 test.built_file_must_match('resource.app/Contents/Resources/secret.txt', |
25 'abc\n', chdir=CHDIR) | 42 'abc\n', chdir=CHDIR) |
26 test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt', | 43 test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt', |
27 'ABC\n', chdir=CHDIR) | 44 'ABC\n', chdir=CHDIR) |
28 | 45 |
| 46 test.built_file_must_match( |
| 47 'resource.app/Contents/Resources/executable-file.sh', |
| 48 '#!/bin/bash\n' |
| 49 '\n' |
| 50 'echo echo echo echo cho ho o o\n', chdir=CHDIR) |
| 51 |
| 52 check_attribs('executable-file.sh', expected_exec_bit=stat.S_IXUSR) |
| 53 check_attribs('secret.txt', expected_exec_bit=0) |
| 54 |
29 # TODO(thakis): This currently fails with make. | 55 # TODO(thakis): This currently fails with make. |
30 if test.format != 'make': | 56 if test.format != 'make': |
31 test.built_file_must_match( | 57 test.built_file_must_match( |
32 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR) | 58 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR) |
33 | 59 |
34 test.pass_test() | 60 test.pass_test() |
OLD | NEW |