Ben Murdoch | 342c50c | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Copyright (c) 2010 Google Inc. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | """ |
| 8 | Tests the use of the NO_LOAD flag which makes loading sub .mk files |
| 9 | optional. |
| 10 | """ |
| 11 | |
| 12 | # Python 2.5 needs this for the with statement. |
| 13 | from __future__ import with_statement |
| 14 | |
| 15 | import os |
| 16 | import TestGyp |
| 17 | |
| 18 | test = TestGyp.TestGyp(formats=['make']) |
| 19 | |
| 20 | test.run_gyp('all.gyp', chdir='noload') |
| 21 | |
| 22 | test.relocate('noload', 'relocate/noload') |
| 23 | |
| 24 | test.build('build/all.gyp', test.ALL, chdir='relocate/noload') |
| 25 | test.run_built_executable('exe', chdir='relocate/noload', |
| 26 | stdout='Hello from shared.c.\n') |
| 27 | |
| 28 | # Just sanity test that NO_LOAD=lib doesn't break anything. |
| 29 | test.build('build/all.gyp', test.ALL, chdir='relocate/noload', |
| 30 | arguments=['NO_LOAD=lib']) |
| 31 | test.run_built_executable('exe', chdir='relocate/noload', |
| 32 | stdout='Hello from shared.c.\n') |
| 33 | test.build('build/all.gyp', test.ALL, chdir='relocate/noload', |
| 34 | arguments=['NO_LOAD=z']) |
| 35 | test.run_built_executable('exe', chdir='relocate/noload', |
| 36 | stdout='Hello from shared.c.\n') |
| 37 | |
| 38 | # Make sure we can rebuild without reloading the sub .mk file. |
| 39 | with open('relocate/noload/main.c', 'a') as src_file: |
| 40 | src_file.write("\n") |
| 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 | |
| 46 | # Change shared.c, but verify that it doesn't get rebuild if we don't load it. |
| 47 | with open('relocate/noload/lib/shared.c', 'w') as shared_file: |
| 48 | shared_file.write( |
| 49 | '#include "shared.h"\n' |
| 50 | 'const char kSharedStr[] = "modified";\n' |
| 51 | ) |
| 52 | test.build('build/all.gyp', test.ALL, chdir='relocate/noload', |
| 53 | arguments=['NO_LOAD=lib']) |
| 54 | test.run_built_executable('exe', chdir='relocate/noload', |
| 55 | stdout='Hello from shared.c.\n') |
| 56 | |
| 57 | test.pass_test() |