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 two actions can be attached to the same input files. 9 """ 10 11 import sys 12 13 import TestGyp 14 15 test = TestGyp.TestGyp() 16 17 test.run_gyp('actions.gyp', chdir='src') 18 19 test.relocate('src', 'relocate/src') 20 21 # Test of fine-grained dependencies for generators that can build individual 22 # files on demand. 23 # In particular: 24 # - TargetA depends on TargetB. 25 # - TargetA and TargetB are 'none' type with actions attached. 26 # - TargetA has multiple actions. 27 # - An output from one of the actions in TargetA (not the first listed), 28 # is requested as the build target. 29 # Ensure that TargetB gets built. 30 # 31 # This sub-test can only be done with generators/build tools that can 32 # be asked to build individual files rather than whole targets (make, ninja). 33 if test.format in ['make', 'ninja']: 34 # Select location of target based on generator. 35 if test.format == 'make': 36 target = 'multi2.txt' 37 elif test.format == 'ninja': 38 if sys.platform in ['win32', 'cygwin']: 39 target = '..\\..\\multi2.txt' 40 else: 41 target = '../../multi2.txt' 42 else: 43 assert False 44 test.build('actions.gyp', chdir='relocate/src', target=target) 45 test.must_contain('relocate/src/multi2.txt', 'hello there') 46 test.must_contain('relocate/src/multi_dep.txt', 'hello there') 47 48 49 # Test that two actions can be attached to the same inputs. 50 test.build('actions.gyp', test.ALL, chdir='relocate/src') 51 test.must_contain('relocate/src/output1.txt', 'hello there') 52 test.must_contain('relocate/src/output2.txt', 'hello there') 53 test.must_contain('relocate/src/output3.txt', 'hello there') 54 test.must_contain('relocate/src/output4.txt', 'hello there') 55 56 # Test that process_outputs_as_sources works in conjuction with merged 57 # actions. 58 test.run_built_executable( 59 'multiple_action_source_filter', 60 chdir='relocate/src', 61 stdout=( 62 '{\n' 63 'bar\n' 64 'car\n' 65 'dar\n' 66 'ear\n' 67 '}\n' 68 ), 69 ) 70 71 72 test.pass_test() 73