| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import cStringIO | 6 import cStringIO |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 self.cwd = cwd | 25 self.cwd = cwd |
| 26 | 26 |
| 27 def __str__(self): | 27 def __str__(self): |
| 28 return super(CalledProcessError, self).__str__() + ( | 28 return super(CalledProcessError, self).__str__() + ( |
| 29 '\n' | 29 '\n' |
| 30 'cwd=%s\n%s') % (self.cwd, self.output) | 30 'cwd=%s\n%s') % (self.cwd, self.output) |
| 31 | 31 |
| 32 | 32 |
| 33 class TraceInputs(unittest.TestCase): | 33 class TraceInputs(unittest.TestCase): |
| 34 def setUp(self): | 34 def setUp(self): |
| 35 self.tempdir = tempfile.mkdtemp() | 35 self.tempdir = tempfile.mkdtemp(prefix='trace_smoke_test') |
| 36 self.log = os.path.join(self.tempdir, 'log') | 36 self.log = os.path.join(self.tempdir, 'log') |
| 37 os.chdir(ROOT_DIR) | 37 os.chdir(ROOT_DIR) |
| 38 | 38 |
| 39 def tearDown(self): | 39 def tearDown(self): |
| 40 shutil.rmtree(self.tempdir) | 40 if VERBOSE: |
| 41 print 'Leaking: %s' % self.tempdir |
| 42 else: |
| 43 shutil.rmtree(self.tempdir) |
| 41 | 44 |
| 42 def _execute(self, is_gyp): | 45 def _execute(self, is_gyp): |
| 43 cmd = [ | 46 cmd = [ |
| 44 sys.executable, os.path.join('..', '..', 'trace_inputs.py'), | 47 sys.executable, os.path.join('..', '..', 'trace_inputs.py'), |
| 45 '--log', self.log, | 48 '--log', self.log, |
| 46 '--root-dir', ROOT_DIR, | 49 '--root-dir', ROOT_DIR, |
| 47 ] | 50 ] |
| 48 if is_gyp: | 51 if is_gyp: |
| 49 cmd.extend( | 52 cmd.extend( |
| 50 [ | 53 [ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 trace_inputs.pretty_print(expected_value, expected_buffer) | 121 trace_inputs.pretty_print(expected_value, expected_buffer) |
| 119 | 122 |
| 120 actual = self._execute(True) | 123 actual = self._execute(True) |
| 121 self.assertEquals(expected_buffer.getvalue(), actual) | 124 self.assertEquals(expected_buffer.getvalue(), actual) |
| 122 | 125 |
| 123 | 126 |
| 124 if __name__ == '__main__': | 127 if __name__ == '__main__': |
| 125 VERBOSE = '-v' in sys.argv | 128 VERBOSE = '-v' in sys.argv |
| 126 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 129 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
| 127 unittest.main() | 130 unittest.main() |
| OLD | NEW |