gyptest-postbuild-copy-bundle.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env python
  2. # Copyright (c) 2012 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 that a postbuild copying a dependend framework into an app bundle is
  7. rerun if the resources in the framework change.
  8. """
  9. import TestGyp
  10. import os.path
  11. import sys
  12. if sys.platform == 'darwin':
  13. # TODO(thakis): Make this pass with the make generator, http://crbug.com/95529
  14. test = TestGyp.TestGyp(formats=['ninja', 'xcode'])
  15. CHDIR = 'postbuild-copy-bundle'
  16. test.run_gyp('test.gyp', chdir=CHDIR)
  17. app_bundle_dir = test.built_file_path('Test App.app', chdir=CHDIR)
  18. bundled_framework_dir = os.path.join(
  19. app_bundle_dir, 'Contents', 'My Framework.framework', 'Resources')
  20. final_plist_path = os.path.join(bundled_framework_dir, 'Info.plist')
  21. final_resource_path = os.path.join(bundled_framework_dir, 'resource_file.sb')
  22. final_copies_path = os.path.join(
  23. app_bundle_dir, 'Contents', 'My Framework.framework', 'Versions', 'A',
  24. 'Libraries', 'copied.txt')
  25. # Check that the dependency was built and copied into the app bundle:
  26. test.build('test.gyp', 'test_app', chdir=CHDIR)
  27. test.must_exist(final_resource_path)
  28. test.must_match(final_resource_path,
  29. 'This is included in the framework bundle.\n')
  30. test.must_exist(final_plist_path)
  31. test.must_contain(final_plist_path, '''\
  32. \t<key>RandomKey</key>
  33. \t<string>RandomValue</string>''')
  34. # Touch the dependency's bundle resource, and check that the modification
  35. # makes it all the way into the app bundle:
  36. test.sleep()
  37. test.write('postbuild-copy-bundle/resource_file.sb', 'New text\n')
  38. test.build('test.gyp', 'test_app', chdir=CHDIR)
  39. test.must_exist(final_resource_path)
  40. test.must_match(final_resource_path, 'New text\n')
  41. # Check the same for the plist file.
  42. test.sleep()
  43. contents = test.read('postbuild-copy-bundle/Framework-Info.plist')
  44. contents = contents.replace('RandomValue', 'NewRandomValue')
  45. test.write('postbuild-copy-bundle/Framework-Info.plist', contents)
  46. test.build('test.gyp', 'test_app', chdir=CHDIR)
  47. test.must_exist(final_plist_path)
  48. test.must_contain(final_plist_path, '''\
  49. \t<key>RandomKey</key>
  50. \t<string>NewRandomValue</string>''')
  51. # Check the same for the copies section, test for http://crbug.com/157077
  52. test.sleep()
  53. contents = test.read('postbuild-copy-bundle/copied.txt')
  54. contents = contents.replace('old', 'new')
  55. test.write('postbuild-copy-bundle/copied.txt', contents)
  56. test.build('test.gyp', 'test_app', chdir=CHDIR)
  57. test.must_exist(final_copies_path)
  58. test.must_contain(final_copies_path, 'new copied file')
  59. test.pass_test()