OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 __doc__ = """ | 7 __doc__ = """ |
8 gyptest.py -- test runner for GYP tests. | 8 gyptest.py -- test runner for GYP tests. |
9 """ | 9 """ |
10 | 10 |
11 import os | 11 import os |
12 import optparse | 12 import optparse |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 class CommandRunner: | 16 class CommandRunner(object): |
17 """ | 17 """ |
18 Executor class for commands, including "commands" implemented by | 18 Executor class for commands, including "commands" implemented by |
19 Python functions. | 19 Python functions. |
20 """ | 20 """ |
21 verbose = True | 21 verbose = True |
22 active = True | 22 active = True |
23 | 23 |
24 def __init__(self, dictionary={}): | 24 def __init__(self, dictionary={}): |
25 self.subst_dictionary(dictionary) | 25 self.subst_dictionary(dictionary) |
26 | 26 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 def run(self, command, display=None, stdout=None, stderr=None): | 110 def run(self, command, display=None, stdout=None, stderr=None): |
111 """ | 111 """ |
112 Runs a single command, displaying it first. | 112 Runs a single command, displaying it first. |
113 """ | 113 """ |
114 if display is None: | 114 if display is None: |
115 display = command | 115 display = command |
116 self.display(display) | 116 self.display(display) |
117 return self.execute(command, stdout, stderr) | 117 return self.execute(command, stdout, stderr) |
118 | 118 |
119 | 119 |
120 class Unbuffered: | 120 class Unbuffered(object): |
121 def __init__(self, fp): | 121 def __init__(self, fp): |
122 self.fp = fp | 122 self.fp = fp |
123 def write(self, arg): | 123 def write(self, arg): |
124 self.fp.write(arg) | 124 self.fp.write(arg) |
125 self.fp.flush() | 125 self.fp.flush() |
126 def __getattr__(self, attr): | 126 def __getattr__(self, attr): |
127 return getattr(self.fp, attr) | 127 return getattr(self.fp, attr) |
128 | 128 |
129 sys.stdout = Unbuffered(sys.stdout) | 129 sys.stdout = Unbuffered(sys.stdout) |
130 sys.stderr = Unbuffered(sys.stderr) | 130 sys.stderr = Unbuffered(sys.stderr) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 report("No result from", no_result) | 265 report("No result from", no_result) |
266 | 266 |
267 if failed: | 267 if failed: |
268 return 1 | 268 return 1 |
269 else: | 269 else: |
270 return 0 | 270 return 0 |
271 | 271 |
272 | 272 |
273 if __name__ == "__main__": | 273 if __name__ == "__main__": |
274 sys.exit(main()) | 274 sys.exit(main()) |
OLD | NEW |