| 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_mtime == out_stat.st_mtime: |
| 25 test.fail_test() |
| 26 if out_stat.st_mode & stat.S_IXUSR != expected_exec_bit: |
| 27 test.fail_test() |
| 28 |
| 29 |
| 15 if sys.platform == 'darwin': | 30 if sys.platform == 'darwin': |
| 16 # set |match| to ignore build stderr output. | 31 # set |match| to ignore build stderr output. |
| 17 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) | 32 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) |
| 18 | 33 |
| 19 CHDIR = 'bundle-resources' | 34 CHDIR = 'bundle-resources' |
| 20 test.run_gyp('test.gyp', chdir=CHDIR) | 35 test.run_gyp('test.gyp', chdir=CHDIR) |
| 21 | 36 |
| 22 test.build('test.gyp', test.ALL, chdir=CHDIR) | 37 test.build('test.gyp', test.ALL, chdir=CHDIR) |
| 23 | 38 |
| 24 test.built_file_must_match('resource.app/Contents/Resources/secret.txt', | 39 test.built_file_must_match('resource.app/Contents/Resources/secret.txt', |
| 25 'abc\n', chdir=CHDIR) | 40 'abc\n', chdir=CHDIR) |
| 26 test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt', | 41 test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt', |
| 27 'ABC\n', chdir=CHDIR) | 42 'ABC\n', chdir=CHDIR) |
| 28 | 43 |
| 44 test.built_file_must_match( |
| 45 'resource.app/Contents/Resources/executable-file.sh', |
| 46 '#!/bin/bash\n' |
| 47 '\n' |
| 48 'echo echo echo echo cho ho o o\n', chdir=CHDIR) |
| 49 |
| 50 check_attribs('executable-file.sh', expected_exec_bit=stat.S_IXUSR) |
| 51 check_attribs('secret.txt', expected_exec_bit=0) |
| 52 |
| 29 # TODO(thakis): This currently fails with make. | 53 # TODO(thakis): This currently fails with make. |
| 30 if test.format != 'make': | 54 if test.format != 'make': |
| 31 test.built_file_must_match( | 55 test.built_file_must_match( |
| 32 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR) | 56 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR) |
| 33 | 57 |
| 34 test.pass_test() | 58 test.pass_test() |
| OLD | NEW |