gyptest-noload.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python
  2. # Copyright (c) 2010 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. Tests the use of the NO_LOAD flag which makes loading sub .mk files
  7. optional.
  8. """
  9. # Python 2.5 needs this for the with statement.
  10. from __future__ import with_statement
  11. import os
  12. import TestGyp
  13. test = TestGyp.TestGyp(formats=['make'])
  14. test.run_gyp('all.gyp', chdir='noload')
  15. test.relocate('noload', 'relocate/noload')
  16. test.build('build/all.gyp', test.ALL, chdir='relocate/noload')
  17. test.run_built_executable('exe', chdir='relocate/noload',
  18. stdout='Hello from shared.c.\n')
  19. # Just sanity test that NO_LOAD=lib doesn't break anything.
  20. test.build('build/all.gyp', test.ALL, chdir='relocate/noload',
  21. arguments=['NO_LOAD=lib'])
  22. test.run_built_executable('exe', chdir='relocate/noload',
  23. stdout='Hello from shared.c.\n')
  24. test.build('build/all.gyp', test.ALL, chdir='relocate/noload',
  25. arguments=['NO_LOAD=z'])
  26. test.run_built_executable('exe', chdir='relocate/noload',
  27. stdout='Hello from shared.c.\n')
  28. # Make sure we can rebuild without reloading the sub .mk file.
  29. with open('relocate/noload/main.c', 'a') as src_file:
  30. src_file.write("\n")
  31. test.build('build/all.gyp', test.ALL, chdir='relocate/noload',
  32. arguments=['NO_LOAD=lib'])
  33. test.run_built_executable('exe', chdir='relocate/noload',
  34. stdout='Hello from shared.c.\n')
  35. # Change shared.c, but verify that it doesn't get rebuild if we don't load it.
  36. with open('relocate/noload/lib/shared.c', 'w') as shared_file:
  37. shared_file.write(
  38. '#include "shared.h"\n'
  39. 'const char kSharedStr[] = "modified";\n'
  40. )
  41. test.build('build/all.gyp', test.ALL, chdir='relocate/noload',
  42. arguments=['NO_LOAD=lib'])
  43. test.run_built_executable('exe', chdir='relocate/noload',
  44. stdout='Hello from shared.c.\n')
  45. test.pass_test()