gyptest-default.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 simple actions when using the default build target.
  7. """
  8. import TestGyp
  9. test = TestGyp.TestGyp(workdir='workarea_default')
  10. test.run_gyp('actions.gyp', chdir='src')
  11. test.relocate('src', 'relocate/src')
  12. # Some gyp files use an action that mentions an output but never
  13. # writes it as a means to making the action run on every build. That
  14. # doesn't mesh well with ninja's semantics. TODO(evan): figure out
  15. # how to work always-run actions in to ninja.
  16. # Android also can't do this as it doesn't have order-only dependencies.
  17. if test.format in ['ninja', 'android', 'xcode-ninja']:
  18. test.build('actions.gyp', test.ALL, chdir='relocate/src')
  19. else:
  20. # Test that an "always run" action increases a counter on multiple
  21. # invocations, and that a dependent action updates in step.
  22. test.build('actions.gyp', chdir='relocate/src')
  23. test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '1')
  24. test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '1')
  25. test.build('actions.gyp', chdir='relocate/src')
  26. test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2')
  27. test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2')
  28. # The "always run" action only counts to 2, but the dependent target
  29. # will count forever if it's allowed to run. This verifies that the
  30. # dependent target only runs when the "always run" action generates
  31. # new output, not just because the "always run" ran.
  32. test.build('actions.gyp', test.ALL, chdir='relocate/src')
  33. test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2')
  34. test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2')
  35. expect = """\
  36. Hello from program.c
  37. Hello from make-prog1.py
  38. Hello from make-prog2.py
  39. """
  40. if test.format == 'xcode':
  41. chdir = 'relocate/src/subdir1'
  42. else:
  43. chdir = 'relocate/src'
  44. test.run_built_executable('program', chdir=chdir, stdout=expect)
  45. test.must_match('relocate/src/subdir2/file.out', "Hello from make-file.py\n")
  46. expect = "Hello from generate_main.py\n"
  47. if test.format == 'xcode':
  48. chdir = 'relocate/src/subdir3'
  49. else:
  50. chdir = 'relocate/src'
  51. test.run_built_executable('null_input', chdir=chdir, stdout=expect)
  52. test.pass_test()