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""" 8Verifies simple actions when using the default build target. 9""" 10 11import TestGyp 12 13test = TestGyp.TestGyp(workdir='workarea_default') 14 15test.run_gyp('actions.gyp', chdir='src') 16 17test.relocate('src', 'relocate/src') 18 19# Some gyp files use an action that mentions an output but never 20# writes it as a means to making the action run on every build. That 21# doesn't mesh well with ninja's semantics. TODO(evan): figure out 22# how to work always-run actions in to ninja. 23# Android also can't do this as it doesn't have order-only dependencies. 24if test.format in ['ninja', 'android']: 25 test.build('actions.gyp', test.ALL, chdir='relocate/src') 26else: 27 # Test that an "always run" action increases a counter on multiple 28 # invocations, and that a dependent action updates in step. 29 test.build('actions.gyp', chdir='relocate/src') 30 test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '1') 31 test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '1') 32 test.build('actions.gyp', chdir='relocate/src') 33 test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') 34 test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') 35 36 # The "always run" action only counts to 2, but the dependent target 37 # will count forever if it's allowed to run. This verifies that the 38 # dependent target only runs when the "always run" action generates 39 # new output, not just because the "always run" ran. 40 test.build('actions.gyp', test.ALL, chdir='relocate/src') 41 test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') 42 test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') 43 44expect = """\ 45Hello from program.c 46Hello from make-prog1.py 47Hello from make-prog2.py 48""" 49 50if test.format == 'xcode': 51 chdir = 'relocate/src/subdir1' 52else: 53 chdir = 'relocate/src' 54test.run_built_executable('program', chdir=chdir, stdout=expect) 55 56 57test.must_match('relocate/src/subdir2/file.out', "Hello from make-file.py\n") 58 59 60expect = "Hello from generate_main.py\n" 61 62if test.format == 'xcode': 63 chdir = 'relocate/src/subdir3' 64else: 65 chdir = 'relocate/src' 66test.run_built_executable('null_input', chdir=chdir, stdout=expect) 67 68 69test.pass_test() 70