blob: 9cd5d47d28bf3e4ba020de4aea355da73eefdf0b [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/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 that a failing postbuild step lets the build fail.
9"""
10
11import TestGyp
12
13import sys
14
15if sys.platform == 'darwin':
16 # set |match| to ignore build stderr output.
17 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'],
18 match = lambda a, b: True)
19
20 test.run_gyp('test.gyp', chdir='postbuild-fail')
21
22 build_error_code = {
23 'xcode': [1, 65], # 1 for xcode 3, 65 for xcode 4 (see `man sysexits`)
24 'make': 2,
25 'ninja': 1,
26 'xcode-ninja': [1, 65],
27 }[test.format]
28
29
30 # If a postbuild fails, all postbuilds should be re-run on the next build.
31 # In Xcode 3, even if the first postbuild fails the other postbuilds were
32 # still executed. In Xcode 4, postbuilds are stopped after the first
33 # failing postbuild. This test checks for the Xcode 4 behavior.
34
35 # Ignore this test on Xcode 3.
36 import subprocess
37 job = subprocess.Popen(['xcodebuild', '-version'],
38 stdout=subprocess.PIPE,
39 stderr=subprocess.STDOUT)
40 out, err = job.communicate()
41 if job.returncode != 0:
42 print out
43 raise Exception('Error %d running xcodebuild' % job.returncode)
44 if out.startswith('Xcode 3.'):
45 test.pass_test()
46
47 # Non-bundles
48 test.build('test.gyp', 'nonbundle', chdir='postbuild-fail',
49 status=build_error_code)
50 test.built_file_must_not_exist('static_touch',
51 chdir='postbuild-fail')
52 # Check for non-up-to-date-ness by checking if building again produces an
53 # error.
54 test.build('test.gyp', 'nonbundle', chdir='postbuild-fail',
55 status=build_error_code)
56
57
58 # Bundles
59 test.build('test.gyp', 'bundle', chdir='postbuild-fail',
60 status=build_error_code)
61 test.built_file_must_not_exist('dynamic_touch',
62 chdir='postbuild-fail')
63 # Check for non-up-to-date-ness by checking if building again produces an
64 # error.
65 test.build('test.gyp', 'bundle', chdir='postbuild-fail',
66 status=build_error_code)
67
68 test.pass_test()