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 | |
28 def RunCommand(cmd, redirect_output=False): | 21 def RunCommand(cmd, redirect_output=False): |
29 try: | 22 try: |
30 if redirect_output: | 23 if redirect_output: |
31 sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT)) | 24 sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT)) |
32 else: | 25 else: |
33 subprocess.check_call(cmd) | 26 subprocess.check_call(cmd) |
34 return None | 27 return None |
35 except subprocess.CalledProcessError as e: | 28 except subprocess.CalledProcessError as e: |
36 return e | 29 return e |
37 | 30 |
38 | |
39 # Adjust Dr. Memory wrapper to have separate log directory for each test | 31 # Adjust Dr. Memory wrapper to have separate log directory for each test |
40 # for better error reporting. | 32 # for better error reporting. |
41 def DrMemoryWrapper(wrapper, pdf_name): | 33 def DrMemoryWrapper(wrapper, pdf_name): |
42 if not wrapper: | 34 if not wrapper: |
43 return [] | 35 return [] |
44 # convert string to list | 36 # convert string to list |
45 cmd_to_run = wrapper.split() | 37 cmd_to_run = wrapper.split() |
46 | 38 |
47 # Do nothing if using default log directory. | 39 # Do nothing if using default log directory. |
48 if cmd_to_run.count("-logdir") == 0: | 40 if cmd_to_run.count("-logdir") == 0: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if other_components: | 106 if other_components: |
115 result = os.path.join(result, other_components) | 107 result = os.path.join(result, other_components) |
116 return result | 108 return result |
117 | 109 |
118 def TestingDir(self, other_components=''): | 110 def TestingDir(self, other_components=''): |
119 '''Finds test files somewhere under the testing directory.''' | 111 '''Finds test files somewhere under the testing directory.''' |
120 result = self.testing_dir | 112 result = self.testing_dir |
121 if other_components: | 113 if other_components: |
122 result = os.path.join(result, other_components) | 114 result = os.path.join(result, other_components) |
123 return result | 115 return result |
OLD | NEW |