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
7import TestGyp
8
9test = TestGyp.TestGyp()
10
11# The xcode-ninja generator handles gypfiles which are not at the
12# project root incorrectly.
13# cf. https://code.google.com/p/gyp/issues/detail?id=460
14if test.format == 'xcode-ninja':
15  test.skip_test()
16
17test.run_gyp('build/all.gyp', chdir='src')
18
19test.build('build/all.gyp', test.ALL, chdir='src')
20
21chdir = 'src/build'
22
23# The top-level Makefile is in the directory where gyp was run.
24# TODO(mmoss) Should the Makefile go in the directory of the passed in .gyp
25# file? What about when passing in multiple .gyp files? Would sub-project
26# Makefiles (see http://codereview.chromium.org/340008 comments) solve this?
27if test.format in ('make', 'ninja', 'cmake'):
28  chdir = 'src'
29
30if test.format == 'xcode':
31  chdir = 'src/prog1'
32test.run_built_executable('program1',
33                          chdir=chdir,
34                          stdout="Hello from prog1.c\n")
35
36if test.format == 'xcode':
37  chdir = 'src/prog2'
38test.run_built_executable('program2',
39                          chdir=chdir,
40                          stdout="Hello from prog2.c\n")
41
42test.pass_test()
43