1 #!/usr/bin/env python 2 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 5 # found in the LICENSE file. 6 7 """ 8 Verifies things related to bundle resources. 9 """ 10 11 import TestGyp 12 13 import os 14 import stat 15 import sys 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 30 if sys.platform == 'darwin': 31 # set |match| to ignore build stderr output. 32 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 33 34 CHDIR = 'bundle-resources' 35 test.run_gyp('test.gyp', chdir=CHDIR) 36 37 test.build('test.gyp', test.ALL, chdir=CHDIR) 38 39 test.built_file_must_match('resource.app/Contents/Resources/secret.txt', 40 'abc\n', chdir=CHDIR) 41 test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt', 42 'ABC\n', chdir=CHDIR) 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 53 # TODO(thakis): This currently fails with make. 54 if test.format != 'make': 55 test.built_file_must_match( 56 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR) 57 58 test.pass_test() 59