gyptest-attribs.py 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 that copying files preserves file attributes.
  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(path, chdir='src')
  14. in_stat = os.stat(os.path.join('src', path))
  15. out_stat = os.stat(out_path)
  16. if out_stat.st_mode & stat.S_IXUSR != expected_exec_bit:
  17. test.fail_test()
  18. test = TestGyp.TestGyp()
  19. test.run_gyp('copies-attribs.gyp', chdir='src')
  20. test.build('copies-attribs.gyp', chdir='src')
  21. if sys.platform != 'win32':
  22. out_path = test.built_file_path('executable-file.sh', chdir='src')
  23. test.must_contain(out_path,
  24. '#!/bin/bash\n'
  25. '\n'
  26. 'echo echo echo echo cho ho o o\n')
  27. check_attribs('executable-file.sh', expected_exec_bit=stat.S_IXUSR)
  28. test.pass_test()