| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The PDFium Authors. All rights reserved. | 2 # Copyright 2015 The PDFium 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 glob | 6 import glob |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 def os_name(): | 11 def os_name(): |
| 12 if sys.platform.startswith('linux'): | 12 if sys.platform.startswith('linux'): |
| 13 return 'linux' | 13 return 'linux' |
| 14 if sys.platform.startswith('win'): | 14 if sys.platform.startswith('win'): |
| 15 return 'win' | 15 return 'win' |
| 16 if sys.platform.startswith('darwin'): | 16 if sys.platform.startswith('darwin'): |
| 17 return 'mac' | 17 return 'mac' |
| 18 raise Exception('Confused, can not determine OS, aborting.') | 18 raise Exception('Confused, can not determine OS, aborting.') |
| 19 | 19 |
| 20 | 20 |
| 21 def RunCommandToFile(cmd, file): |
| 22 try: |
| 23 subprocess.check_call(cmd, stdout=file) |
| 24 return None |
| 25 except subprocess.CalledProcessError as e: |
| 26 return e |
| 27 |
| 21 def RunCommand(cmd, redirect_output=False): | 28 def RunCommand(cmd, redirect_output=False): |
| 22 try: | 29 try: |
| 23 if redirect_output: | 30 if redirect_output: |
| 24 sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT)) | 31 sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT)) |
| 25 else: | 32 else: |
| 26 subprocess.check_call(cmd) | 33 subprocess.check_call(cmd) |
| 27 return None | 34 return None |
| 28 except subprocess.CalledProcessError as e: | 35 except subprocess.CalledProcessError as e: |
| 29 return e | 36 return e |
| 30 | 37 |
| 38 |
| 31 # Adjust Dr. Memory wrapper to have separate log directory for each test | 39 # Adjust Dr. Memory wrapper to have separate log directory for each test |
| 32 # for better error reporting. | 40 # for better error reporting. |
| 33 def DrMemoryWrapper(wrapper, pdf_name): | 41 def DrMemoryWrapper(wrapper, pdf_name): |
| 34 if not wrapper: | 42 if not wrapper: |
| 35 return [] | 43 return [] |
| 36 # convert string to list | 44 # convert string to list |
| 37 cmd_to_run = wrapper.split() | 45 cmd_to_run = wrapper.split() |
| 38 | 46 |
| 39 # Do nothing if using default log directory. | 47 # Do nothing if using default log directory. |
| 40 if cmd_to_run.count("-logdir") == 0: | 48 if cmd_to_run.count("-logdir") == 0: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 if other_components: | 114 if other_components: |
| 107 result = os.path.join(result, other_components) | 115 result = os.path.join(result, other_components) |
| 108 return result | 116 return result |
| 109 | 117 |
| 110 def TestingDir(self, other_components=''): | 118 def TestingDir(self, other_components=''): |
| 111 '''Finds test files somewhere under the testing directory.''' | 119 '''Finds test files somewhere under the testing directory.''' |
| 112 result = self.testing_dir | 120 result = self.testing_dir |
| 113 if other_components: | 121 if other_components: |
| 114 result = os.path.join(result, other_components) | 122 result = os.path.join(result, other_components) |
| 115 return result | 123 return result |
| OLD | NEW |