Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/test/functional/pyauto_functional.py

Issue 222873002: Remove pyauto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/functional/prefs_ui.py ('k') | chrome/test/functional/pyauto_webdriver.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """Setup for PyAuto functional tests.
7
8 Use the following in your scripts to run them standalone:
9
10 # This should be at the top
11 import pyauto_functional
12
13 if __name__ == '__main__':
14 pyauto_functional.Main()
15
16 This script can be used as an executable to fire off other scripts, similar
17 to unittest.py
18 python pyauto_functional.py test_script
19 """
20
21 import os
22 import subprocess
23 import sys
24
25
26 def _LocatePyAutoDir():
27 sys.path.append(os.path.join(os.path.dirname(__file__),
28 os.pardir, 'pyautolib'))
29
30
31 _LocatePyAutoDir()
32 import pyauto_paths
33
34
35 def RunWithCorrectPythonIfNecessary():
36 """Runs this script with the correct version of python if necessary.
37
38 Different platforms and versions of pyautolib use different python versions.
39 Instead of requiring testers and infrastructure to handle choosing the right
40 version (and architecture), this will rerun the script with the correct
41 version of python.
42
43 Note, this function will either return after doing nothing, or will exit with
44 the subprocess's return code.
45 """
46 def RunAgain():
47 """Run the script again with the correct version of python.
48
49 Note, this function does not return, but exits with the return code of the
50 child.
51 """
52 if sys.platform == 'cygwin' or sys.platform.startswith('win'):
53 cmd = [sys.executable]
54 elif sys.platform.startswith('darwin'):
55 # Arch runs the specified architecture of a universal binary. Run
56 # the 32 bit one.
57 cmd = ['arch', '-i386', 'python2.6']
58 elif sys.platform.startswith('linux'):
59 cmd = ['python2.6']
60
61 cmd.extend(sys.argv)
62 print 'Running:', ' '.join(cmd)
63 proc = subprocess.Popen(cmd)
64 proc.wait()
65 sys.exit(proc.returncode)
66
67 def IsChromeOS():
68 lsb_release = '/etc/lsb-release'
69 if sys.platform.startswith('linux') and os.path.isfile(lsb_release):
70 with open(lsb_release) as fp:
71 contents = fp.read()
72 return 'CHROMEOS_RELEASE_NAME=' in contents
73 return False
74
75 # Ensure this is the right python version (2.6 for chrome, 2.7 for chromeOS).
76 if IsChromeOS():
77 if sys.version_info[0:2] != (2, 7):
78 cmd = ['python2.7'] + sys.argv
79 print 'Running: ', ' '.join(cmd)
80 proc = subprocess.Popen(cmd)
81 proc.wait()
82 else:
83 if sys.version_info[0:2] != (2, 6):
84 RunAgain()
85
86 # Check this is the right bitness on mac.
87 # platform.architecture() will not help us on mac, since multiple binaries
88 # are stuffed inside the universal python binary.
89 if sys.platform.startswith('darwin') and sys.maxint > 2**32:
90 # User is running 64-bit python, but we should use 32-bit.
91 RunAgain()
92
93
94 # Do not attempt to figure out python versions if
95 # DO_NOT_RESTART_PYTHON_FOR_PYAUTO is set.
96 if os.getenv('DO_NOT_RESTART_PYTHON_FOR_PYAUTO') is None:
97 RunWithCorrectPythonIfNecessary()
98 else:
99 print 'Will not try to restart with the correct version of python '\
100 'as DO_NOT_RESTART_PYTHON_FOR_PYAUTO is set.'
101
102
103 try:
104 import pyauto
105 except ImportError:
106 print >>sys.stderr, 'Cannot import pyauto from %s' % sys.path
107 raise
108
109
110 class Main(pyauto.Main):
111 """Main program for running PyAuto functional tests."""
112
113 def __init__(self):
114 # Make scripts in this dir importable
115 sys.path.append(os.path.dirname(__file__))
116 pyauto.Main.__init__(self)
117
118 def TestsDir(self):
119 return os.path.dirname(__file__)
120
121
122 if __name__ == '__main__':
123 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/prefs_ui.py ('k') | chrome/test/functional/pyauto_webdriver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698