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