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