OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Setup for PyAuto functional tests. | 6 """Setup for PyAuto functional tests. |
7 | 7 |
8 Use the following in your scripts to run them standalone: | 8 Use the following in your scripts to run them standalone: |
9 | 9 |
10 # This should be at the top | 10 # This should be at the top |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 elif sys.platform.startswith('linux'): | 59 elif sys.platform.startswith('linux'): |
60 cmd = ['python2.6'] | 60 cmd = ['python2.6'] |
61 | 61 |
62 cmd.extend(sys.argv) | 62 cmd.extend(sys.argv) |
63 print 'Running:', ' '.join(cmd) | 63 print 'Running:', ' '.join(cmd) |
64 proc = subprocess.Popen(cmd) | 64 proc = subprocess.Popen(cmd) |
65 proc.wait() | 65 proc.wait() |
66 sys.exit(proc.returncode) | 66 sys.exit(proc.returncode) |
67 | 67 |
68 # Check this is the right python version. | 68 # Check this is the right python version. |
69 if sys.version_info[0:2] != (2, 6): | 69 # Also check the environment variable DO_NOT_RESTART_PYTHON_FOR_PYAUTO. If |
70 # it is set to TRUE (case-insensitive), then do not run RunAgain() regardless | |
71 # what current python version is. | |
72 | |
73 if (sys.version_info[0:2] != (2, 6) and | |
74 (os.getenv('DO_NOT_RESTART_PYTHON_FOR_PYAUTO') is None or | |
75 os.getenv('DO_NOT_RESTART_PYTHON_FOR_PYAUTO').upper() != 'TRUE')): | |
70 RunAgain() | 76 RunAgain() |
71 | 77 |
72 # Check this is the right bitness on mac. | 78 # Check this is the right bitness on mac. |
73 # platform.architecture() will not help us on mac, since multiple binaries | 79 # platform.architecture() will not help us on mac, since multiple binaries |
74 # are stuffed inside the universal python binary. | 80 # are stuffed inside the universal python binary. |
75 if sys.platform.startswith('darwin') and sys.maxint > 2**32: | 81 if sys.platform.startswith('darwin') and sys.maxint > 2**32: |
76 # User is running 64-bit python, but we should use 32-bit. | 82 # User is running 64-bit python, but we should use 32-bit. |
77 RunAgain() | 83 RunAgain() |
78 | 84 |
79 | 85 |
80 RunWithCorrectPythonIfNecessary() | 86 RunWithCorrectPythonIfNecessary() |
dennis_jeffrey
2012/07/04 01:04:18
It might make more sense to add the check here. W
fdeng1
2012/07/09 20:52:37
I've moved the check here.
On 2012/07/04 01:04:18,
| |
81 | 87 |
82 | 88 |
83 try: | 89 try: |
84 import pyauto | 90 import pyauto |
85 except ImportError: | 91 except ImportError: |
86 print >>sys.stderr, 'Cannot import pyauto from %s' % sys.path | 92 print >>sys.stderr, 'Cannot import pyauto from %s' % sys.path |
87 raise | 93 raise |
88 | 94 |
89 | 95 |
90 class Main(pyauto.Main): | 96 class Main(pyauto.Main): |
91 """Main program for running PyAuto functional tests.""" | 97 """Main program for running PyAuto functional tests.""" |
92 | 98 |
93 def __init__(self): | 99 def __init__(self): |
94 # Make scripts in this dir importable | 100 # Make scripts in this dir importable |
95 sys.path.append(os.path.dirname(__file__)) | 101 sys.path.append(os.path.dirname(__file__)) |
96 pyauto.Main.__init__(self) | 102 pyauto.Main.__init__(self) |
97 | 103 |
98 def TestsDir(self): | 104 def TestsDir(self): |
99 return os.path.dirname(__file__) | 105 return os.path.dirname(__file__) |
100 | 106 |
101 | 107 |
102 if __name__ == '__main__': | 108 if __name__ == '__main__': |
103 Main() | 109 Main() |
OLD | NEW |