1#!/usr/bin/env python
2
3# Copyright (c) 2011 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 rules when using an explicit build target of 'all'.
9"""
10
11import TestGyp
12
13test = TestGyp.TestGyp()
14
15test.run_gyp('no_action_with_rules_fails.gyp', chdir='src/noaction', status=1,
16             stderr=None)
17
18test.run_gyp('actions.gyp', chdir='src')
19
20test.relocate('src', 'relocate/src')
21
22test.build('actions.gyp', test.ALL, chdir='relocate/src')
23
24expect = """\
25Hello from program.c
26Hello from function1.in
27Hello from function2.in
28"""
29
30if test.format == 'xcode':
31  chdir = 'relocate/src/subdir1'
32else:
33  chdir = 'relocate/src'
34test.run_built_executable('program', chdir=chdir, stdout=expect)
35
36expect = """\
37Hello from program.c
38Hello from function3.in
39"""
40
41if test.format == 'xcode':
42  chdir = 'relocate/src/subdir3'
43else:
44  chdir = 'relocate/src'
45test.run_built_executable('program2', chdir=chdir, stdout=expect)
46
47test.must_match('relocate/src/subdir2/file1.out', 'Hello from file1.in\n')
48test.must_match('relocate/src/subdir2/file2.out', 'Hello from file2.in\n')
49
50test.must_match('relocate/src/subdir2/file1.out2', 'Hello from file1.in\n')
51test.must_match('relocate/src/subdir2/file2.out2', 'Hello from file2.in\n')
52
53test.must_match('relocate/src/subdir2/file1.out4', 'Hello from file1.in\n')
54test.must_match('relocate/src/subdir2/file2.out4', 'Hello from file2.in\n')
55test.must_match('relocate/src/subdir2/file1.copy', 'Hello from file1.in\n')
56
57test.must_match('relocate/src/external/file1.external_rules.out',
58                'Hello from file1.in\n')
59test.must_match('relocate/src/external/file2.external_rules.out',
60                'Hello from file2.in\n')
61
62expect = """\
63Hello from program.c
64Got 41.
65"""
66
67if test.format == 'xcode':
68  chdir = 'relocate/src/subdir4'
69else:
70  chdir = 'relocate/src'
71test.run_built_executable('program4', chdir=chdir, stdout=expect)
72
73test.pass_test()
74