1 #!/usr/bin/env python 2 3 # Copyright (c) 2012 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 Verifies that a rule that generates multiple outputs rebuilds 9 correctly when the inputs change. 10 """ 11 12 import TestGyp 13 14 test = TestGyp.TestGyp(workdir='workarea_default') 15 16 test.run_gyp('same_target.gyp', chdir='src') 17 18 test.relocate('src', 'relocate/src') 19 20 21 test.build('same_target.gyp', chdir='relocate/src') 22 23 expect = """\ 24 Hello from main.c 25 Hello from prog1.in! 26 Hello from prog2.in! 27 """ 28 29 test.run_built_executable('program', chdir='relocate/src', stdout=expect) 30 31 test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') 32 33 34 test.sleep() 35 contents = test.read(['relocate', 'src', 'prog1.in']) 36 contents = contents.replace('!', ' AGAIN!') 37 test.write(['relocate', 'src', 'prog1.in'], contents) 38 39 test.build('same_target.gyp', chdir='relocate/src') 40 41 expect = """\ 42 Hello from main.c 43 Hello from prog1.in AGAIN! 44 Hello from prog2.in! 45 """ 46 47 test.run_built_executable('program', chdir='relocate/src', stdout=expect) 48 49 test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') 50 51 52 test.sleep() 53 contents = test.read(['relocate', 'src', 'prog2.in']) 54 contents = contents.replace('!', ' AGAIN!') 55 test.write(['relocate', 'src', 'prog2.in'], contents) 56 57 test.build('same_target.gyp', chdir='relocate/src') 58 59 expect = """\ 60 Hello from main.c 61 Hello from prog1.in AGAIN! 62 Hello from prog2.in AGAIN! 63 """ 64 65 test.run_built_executable('program', chdir='relocate/src', stdout=expect) 66 67 test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') 68 69 70 # Test that modifying a rule's inputs (specifically, make-sources.py) causes 71 # the targets to be built. 72 73 test.sleep() 74 contents = test.read(['relocate', 'src', 'make-sources.py']) 75 contents = contents.replace('%s', 'the amazing %s') 76 test.write(['relocate', 'src', 'make-sources.py'], contents) 77 78 test.build('same_target.gyp', chdir='relocate/src') 79 80 expect = """\ 81 Hello from main.c 82 Hello from the amazing prog1.in AGAIN! 83 Hello from the amazing prog2.in AGAIN! 84 """ 85 86 test.run_built_executable('program', chdir='relocate/src', stdout=expect) 87 88 test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') 89 90 91 test.pass_test() 92