gyptest-bundle-resources.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python
  2. # Copyright (c) 2013 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """
  6. Verifies things related to bundle resources.
  7. """
  8. import TestGyp
  9. import os
  10. import stat
  11. import sys
  12. def check_attribs(path, expected_exec_bit):
  13. out_path = test.built_file_path(
  14. os.path.join('resource.app/Contents/Resources', path), chdir=CHDIR)
  15. in_stat = os.stat(os.path.join(CHDIR, path))
  16. out_stat = os.stat(out_path)
  17. if in_stat.st_mtime == out_stat.st_mtime:
  18. test.fail_test()
  19. if out_stat.st_mode & stat.S_IXUSR != expected_exec_bit:
  20. test.fail_test()
  21. if sys.platform == 'darwin':
  22. # set |match| to ignore build stderr output.
  23. test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
  24. CHDIR = 'bundle-resources'
  25. test.run_gyp('test.gyp', chdir=CHDIR)
  26. test.build('test.gyp', test.ALL, chdir=CHDIR)
  27. test.built_file_must_match('resource.app/Contents/Resources/secret.txt',
  28. 'abc\n', chdir=CHDIR)
  29. test.built_file_must_match('source_rule.app/Contents/Resources/secret.txt',
  30. 'ABC\n', chdir=CHDIR)
  31. test.built_file_must_match(
  32. 'resource.app/Contents/Resources/executable-file.sh',
  33. '#!/bin/bash\n'
  34. '\n'
  35. 'echo echo echo echo cho ho o o\n', chdir=CHDIR)
  36. check_attribs('executable-file.sh', expected_exec_bit=stat.S_IXUSR)
  37. check_attribs('secret.txt', expected_exec_bit=0)
  38. # TODO(thakis): This currently fails with make.
  39. if test.format != 'make':
  40. test.built_file_must_match(
  41. 'resource_rule.app/Contents/Resources/secret.txt', 'ABC\n', chdir=CHDIR)
  42. test.pass_test()