OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import json | 5 import json |
6 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import pipes | 8 import pipes |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
11 | 11 |
12 import buildbot_report | |
frankf
2013/07/09 00:37:56
I think the convention is bb_*. It might makes sen
| |
13 | |
12 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 14 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
13 from pylib import buildbot_report | 15 from pylib import constants |
14 | 16 |
15 | 17 |
16 TESTING = 'BUILDBOT_TESTING' in os.environ | 18 TESTING = 'BUILDBOT_TESTING' in os.environ |
17 | 19 |
18 BB_BUILD_DIR = os.path.abspath( | 20 BB_BUILD_DIR = os.path.abspath( |
19 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, | 21 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, |
20 os.pardir, os.pardir, os.pardir, os.pardir)) | 22 os.pardir, os.pardir, os.pardir, os.pardir)) |
21 | 23 |
22 CHROME_SRC = os.path.abspath( | 24 CHROME_SRC = os.path.abspath( |
23 os.path.join(os.path.dirname(__file__), '..', '..', '..')) | 25 os.path.join(os.path.dirname(__file__), '..', '..', '..')) |
(...skipping 11 matching lines...) Expand all Loading... | |
35 sys.stdout.flush() | 37 sys.stdout.flush() |
36 if TESTING: | 38 if TESTING: |
37 class MockPopen(object): | 39 class MockPopen(object): |
38 @staticmethod | 40 @staticmethod |
39 def wait(): | 41 def wait(): |
40 return 0 | 42 return 0 |
41 return MockPopen() | 43 return MockPopen() |
42 return subprocess.Popen(command, cwd=CHROME_SRC, stdout=stdout) | 44 return subprocess.Popen(command, cwd=CHROME_SRC, stdout=stdout) |
43 | 45 |
44 | 46 |
45 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, | 47 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, stdout=None): |
46 warning_code=88, stdout=None): | |
47 """Run a command relative to the chrome source root.""" | 48 """Run a command relative to the chrome source root.""" |
48 code = SpawnCmd(command, stdout).wait() | 49 code = SpawnCmd(command, stdout).wait() |
49 print '<', CommandToString(command) | 50 print '<', CommandToString(command) |
50 if code != 0: | 51 if code != 0: |
51 print 'ERROR: process exited with code %d' % code | 52 print 'ERROR: process exited with code %d' % code |
52 if code != warning_code and flunk_on_failure: | 53 if code != constants.WARNING_EXIT_CODE and flunk_on_failure: |
frankf
2013/07/09 00:37:56
You're assuming every arbitrary command uses our w
gkanwar
2013/07/09 00:47:42
Ah my mistake. Switched back to a default paramete
| |
53 buildbot_report.PrintError() | 54 buildbot_report.PrintError() |
54 else: | 55 else: |
55 buildbot_report.PrintWarning() | 56 buildbot_report.PrintWarning() |
56 # Allow steps to have both halting (i.e. 1) and non-halting exit codes. | 57 # Allow steps to have both halting (i.e. 1) and non-halting exit codes. |
57 if code != warning_code and halt_on_failure: | 58 if code != constants.WARNING_EXIT_CODE and halt_on_failure: |
58 print 'FATAL %d != %d' % (code, warning_code) | 59 print 'FATAL %d != %d' % (code, constants.WARNING_EXIT_CODE) |
59 sys.exit(1) | 60 sys.exit(1) |
60 return code | 61 return code |
61 | 62 |
62 | 63 |
63 def GetParser(): | 64 def GetParser(): |
64 def ConvertJson(option, _, value, parser): | 65 def ConvertJson(option, _, value, parser): |
65 setattr(parser.values, option.dest, json.loads(value)) | 66 setattr(parser.values, option.dest, json.loads(value)) |
66 parser = optparse.OptionParser() | 67 parser = optparse.OptionParser() |
67 parser.add_option('--build-properties', action='callback', | 68 parser.add_option('--build-properties', action='callback', |
68 callback=ConvertJson, type='string', default={}, | 69 callback=ConvertJson, type='string', default={}, |
(...skipping 11 matching lines...) Expand all Loading... | |
80 | 81 |
81 def RunSteps(steps, step_cmds, options): | 82 def RunSteps(steps, step_cmds, options): |
82 unknown_steps = set(steps) - set(step for step, _ in step_cmds) | 83 unknown_steps = set(steps) - set(step for step, _ in step_cmds) |
83 if unknown_steps: | 84 if unknown_steps: |
84 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps) | 85 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps) |
85 sys.exit(1) | 86 sys.exit(1) |
86 | 87 |
87 for step, cmd in step_cmds: | 88 for step, cmd in step_cmds: |
88 if step in steps: | 89 if step in steps: |
89 cmd(options) | 90 cmd(options) |
OLD | NEW |