gyptest-default.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 rule that generates multiple outputs rebuilds
  7. correctly when the inputs change.
  8. """
  9. import TestGyp
  10. test = TestGyp.TestGyp(workdir='workarea_default')
  11. test.run_gyp('same_target.gyp', chdir='src')
  12. test.relocate('src', 'relocate/src')
  13. test.build('same_target.gyp', chdir='relocate/src')
  14. expect = """\
  15. Hello from main.c
  16. Hello from prog1.in!
  17. Hello from prog2.in!
  18. """
  19. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  20. test.up_to_date('same_target.gyp', 'program', chdir='relocate/src')
  21. test.sleep()
  22. contents = test.read(['relocate', 'src', 'prog1.in'])
  23. contents = contents.replace('!', ' AGAIN!')
  24. test.write(['relocate', 'src', 'prog1.in'], contents)
  25. test.build('same_target.gyp', chdir='relocate/src')
  26. expect = """\
  27. Hello from main.c
  28. Hello from prog1.in AGAIN!
  29. Hello from prog2.in!
  30. """
  31. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  32. test.up_to_date('same_target.gyp', 'program', chdir='relocate/src')
  33. test.sleep()
  34. contents = test.read(['relocate', 'src', 'prog2.in'])
  35. contents = contents.replace('!', ' AGAIN!')
  36. test.write(['relocate', 'src', 'prog2.in'], contents)
  37. test.build('same_target.gyp', chdir='relocate/src')
  38. expect = """\
  39. Hello from main.c
  40. Hello from prog1.in AGAIN!
  41. Hello from prog2.in AGAIN!
  42. """
  43. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  44. test.up_to_date('same_target.gyp', 'program', chdir='relocate/src')
  45. # Test that modifying a rule's inputs (specifically, make-sources.py) causes
  46. # the targets to be built.
  47. test.sleep()
  48. contents = test.read(['relocate', 'src', 'make-sources.py'])
  49. contents = contents.replace('%s', 'the amazing %s')
  50. test.write(['relocate', 'src', 'make-sources.py'], contents)
  51. test.build('same_target.gyp', chdir='relocate/src')
  52. expect = """\
  53. Hello from main.c
  54. Hello from the amazing prog1.in AGAIN!
  55. Hello from the amazing prog2.in AGAIN!
  56. """
  57. test.run_built_executable('program', chdir='relocate/src', stdout=expect)
  58. test.up_to_date('same_target.gyp', 'program', chdir='relocate/src')
  59. test.pass_test()