gyptest-postbuild-fail.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env python
  2. # Copyright (c) 2011 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 failing postbuild step lets the build fail.
  7. """
  8. import TestGyp
  9. import sys
  10. if sys.platform == 'darwin':
  11. # set |match| to ignore build stderr output.
  12. test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'],
  13. match = lambda a, b: True)
  14. test.run_gyp('test.gyp', chdir='postbuild-fail')
  15. build_error_code = {
  16. 'xcode': [1, 65], # 1 for xcode 3, 65 for xcode 4 (see `man sysexits`)
  17. 'make': 2,
  18. 'ninja': 1,
  19. }[test.format]
  20. # If a postbuild fails, all postbuilds should be re-run on the next build.
  21. # In Xcode 3, even if the first postbuild fails the other postbuilds were
  22. # still executed. In Xcode 4, postbuilds are stopped after the first
  23. # failing postbuild. This test checks for the Xcode 4 behavior.
  24. # Ignore this test on Xcode 3.
  25. import subprocess
  26. job = subprocess.Popen(['xcodebuild', '-version'],
  27. stdout=subprocess.PIPE,
  28. stderr=subprocess.STDOUT)
  29. out, err = job.communicate()
  30. if job.returncode != 0:
  31. print out
  32. raise Exception('Error %d running xcodebuild' % job.returncode)
  33. if out.startswith('Xcode 3.'):
  34. test.pass_test()
  35. # Non-bundles
  36. test.build('test.gyp', 'nonbundle', chdir='postbuild-fail',
  37. status=build_error_code)
  38. test.built_file_must_not_exist('static_touch',
  39. chdir='postbuild-fail')
  40. # Check for non-up-to-date-ness by checking if building again produces an
  41. # error.
  42. test.build('test.gyp', 'nonbundle', chdir='postbuild-fail',
  43. status=build_error_code)
  44. # Bundles
  45. test.build('test.gyp', 'bundle', chdir='postbuild-fail',
  46. status=build_error_code)
  47. test.built_file_must_not_exist('dynamic_touch',
  48. chdir='postbuild-fail')
  49. # Check for non-up-to-date-ness by checking if building again produces an
  50. # error.
  51. test.build('test.gyp', 'bundle', chdir='postbuild-fail',
  52. status=build_error_code)
  53. test.pass_test()