Loading testing/tps/README +18 −10 Original line number Diff line number Diff line Loading @@ -7,23 +7,28 @@ Installation TPS requires several packages to operate properly. To install TPS and required packages, use the INSTALL.sh script, provided: python create_venv.py /path/to/create/virtualenv python3 create_venv.py /path/to/create/virtualenv This script will create a virtalenv and install TPS into it. TPS can then be run by activating the virtualenv and executing: This script will create a virtalenv and install TPS into it. You must then activate the virtualenv by executing: - (linux): source /path/to/virtualenv/Scripts/activate - (win): /path/to/virtualenv/Scripts/activate.bat TPS can then be run by executing: runtps --binary=/path/to/firefox When you are done with TPS, you can deactivate the virtualenv by executing `deactivate` Configuration ============= To edit the TPS configuration, do not edit config/config.json.in in the tree. Instead, edit config.json inside your virtualenv; it will be located at something like: (linux): /path/to/virtualenv/lib/python2.6/site-packages/tps-0.2.40-py2.6.egg/tps/config.json (win): /path/to/virtualenv/Lib/site-packages/tps-0.2.40-py2.6.egg/tps/config.json Instead, edit config.json inside your virtualenv; it will be located at the top level of where you specified the virtualenv be created - eg, for the example above, it will be `/path/to/create/virtualenv/config.json` Setting Up Test Accounts ======================== Loading @@ -39,4 +44,7 @@ following steps: 4. Go back to the Restmail URL, reload the page 5. Search for the verification link and open that page Now you will be able to use your setup Firefox Account for Sync. Now you will be able to use this account for TPS. Note that these steps can be done in either a test profile or in a private browsing window - you might want to avoid doing that in a "real" profile that's already connected to Sync. testing/tps/create_venv.py +38 −54 Original line number Diff line number Diff line #!/usr/bin/env python #!/usr/bin/env python3 # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. Loading @@ -9,15 +9,11 @@ It's probably best to specify a path NOT inside the repo, otherwise all the virtualenv files will show up in e.g. hg status. """ from __future__ import absolute_import, print_function import six import optparse import os import shutil import subprocess import sys import zipfile import venv here = os.path.dirname(os.path.abspath(__file__)) Loading @@ -38,58 +34,18 @@ See runtps --help for all options *********************************************************************** """ # Link to the folder, which contains the zip archives of virtualenv URL_VIRTUALENV = "https://codeload.github.com/pypa/virtualenv/zip/" VERSION_VIRTUALENV = "15.0.0" if sys.platform == "win32": bin_name = os.path.join("Scripts", "activate.bat") activate_env = os.path.join("Scripts", "activate_this.py") python_env = os.path.join("Scripts", "python.exe") else: bin_name = os.path.join("bin", "activate") activate_env = os.path.join("bin", "activate_this.py") python_env = os.path.join("bin", "python") def download(url, target): """Downloads the specified url to the given target.""" response = six.moves.urllib.request.urlopen(url) with open(target, "wb") as f: f.write(response.read()) return target def setup_virtualenv(target, python_bin=None): script_path = os.path.join( here, "virtualenv-%s" % VERSION_VIRTUALENV, "virtualenv.py" ) print("Downloading virtualenv {}".format(VERSION_VIRTUALENV)) zip_path = download( URL_VIRTUALENV + VERSION_VIRTUALENV, os.path.join(here, "virtualenv.zip") ) try: with zipfile.ZipFile(zip_path, "r") as f: f.extractall(here) print("Creating new virtual environment") cmd_args = [sys.executable, script_path, target] if python_bin: cmd_args.extend(["-p", python_bin]) subprocess.check_call(cmd_args) finally: try: os.remove(zip_path) except OSError: pass shutil.rmtree(os.path.dirname(script_path), ignore_errors=True) def setup_virtualenv(target): print("Creating new virtual environment:", os.path.abspath(target)) # system_site_packages=True so we have access to setuptools. venv.create(target, system_site_packages=True) def update_configfile(source, target, replacements): Loading @@ -97,7 +53,7 @@ def update_configfile(source, target, replacements): with open(source) as config: for line in config: for source_string, target_string in six.iteritems(replacements): for source_string, target_string in replacements.items(): if target_string: line = line.replace(source_string, target_string) lines.append(line) Loading Loading @@ -172,11 +128,10 @@ def main(): target = args[0] assert target setup_virtualenv(target, python_bin=options.python) setup_virtualenv(target) # Activate tps environment tps_env = os.path.join(target, activate_env) exec(open(tps_env).read(), dict(__file__=tps_env)) activate(target) # Install TPS in environment subprocess.check_call( Loading Loading @@ -217,5 +172,34 @@ def main(): print(usage_message.format(TARGET=target, BIN_NAME=bin_name)) def activate(target): # This is a lightly modified copy of `activate_this.py`, which existed when # venv was an external package, but doesn't come with the builtin venv support. old_os_path = os.environ.get("PATH", "") os.environ["PATH"] = ( os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path ) base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if sys.platform == "win32": site_packages = os.path.join(base, "Lib", "site-packages") else: site_packages = os.path.join( base, "lib", "python%s" % sys.version[:3], "site-packages" ) prev_sys_path = list(sys.path) import site site.addsitedir(site_packages) sys.real_prefix = sys.prefix sys.prefix = base # Move the added items to the front of the path: new_sys_path = [] for item in list(sys.path): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) sys.path[:0] = new_sys_path if __name__ == "__main__": main() testing/tps/mach_commands.py +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, # You can obtain one at http://mozilla.org/MPL/2.0/. from __future__ import absolute_import, print_function import os from mach.decorators import Command, CommandArgument Loading testing/tps/setup.py +6 −12 Original line number Diff line number Diff line Loading @@ -2,30 +2,24 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from __future__ import absolute_import from setuptools import setup, find_packages import sys version = "0.6" deps = [ "httplib2 == 0.9.2", "mozfile >= 1.2", "mozhttpd == 0.7", "mozinfo >= 0.10", "mozinstall == 1.16", "mozprocess == 0.26", "wptserve >= 3.0", "mozinfo >= 1.2", "mozinstall == 2.0.1", "mozprocess == 1.3", "mozprofile ~= 2.1", "mozrunner ~= 7.2", "mozversion == 1.5", "mozrunner ~= 8.2", "mozversion == 2.3", "PyYAML >= 4.0", ] # we only support python 2.6+ right now assert sys.version_info[0] == 2 assert sys.version_info[1] >= 6 setup( name="tps", version=version, Loading testing/tps/tps/__init__.py +0 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ # flake8: noqa from __future__ import absolute_import from .firefoxrunner import TPSFirefoxRunner from .testrunner import TPSTestRunner Loading
testing/tps/README +18 −10 Original line number Diff line number Diff line Loading @@ -7,23 +7,28 @@ Installation TPS requires several packages to operate properly. To install TPS and required packages, use the INSTALL.sh script, provided: python create_venv.py /path/to/create/virtualenv python3 create_venv.py /path/to/create/virtualenv This script will create a virtalenv and install TPS into it. TPS can then be run by activating the virtualenv and executing: This script will create a virtalenv and install TPS into it. You must then activate the virtualenv by executing: - (linux): source /path/to/virtualenv/Scripts/activate - (win): /path/to/virtualenv/Scripts/activate.bat TPS can then be run by executing: runtps --binary=/path/to/firefox When you are done with TPS, you can deactivate the virtualenv by executing `deactivate` Configuration ============= To edit the TPS configuration, do not edit config/config.json.in in the tree. Instead, edit config.json inside your virtualenv; it will be located at something like: (linux): /path/to/virtualenv/lib/python2.6/site-packages/tps-0.2.40-py2.6.egg/tps/config.json (win): /path/to/virtualenv/Lib/site-packages/tps-0.2.40-py2.6.egg/tps/config.json Instead, edit config.json inside your virtualenv; it will be located at the top level of where you specified the virtualenv be created - eg, for the example above, it will be `/path/to/create/virtualenv/config.json` Setting Up Test Accounts ======================== Loading @@ -39,4 +44,7 @@ following steps: 4. Go back to the Restmail URL, reload the page 5. Search for the verification link and open that page Now you will be able to use your setup Firefox Account for Sync. Now you will be able to use this account for TPS. Note that these steps can be done in either a test profile or in a private browsing window - you might want to avoid doing that in a "real" profile that's already connected to Sync.
testing/tps/create_venv.py +38 −54 Original line number Diff line number Diff line #!/usr/bin/env python #!/usr/bin/env python3 # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. Loading @@ -9,15 +9,11 @@ It's probably best to specify a path NOT inside the repo, otherwise all the virtualenv files will show up in e.g. hg status. """ from __future__ import absolute_import, print_function import six import optparse import os import shutil import subprocess import sys import zipfile import venv here = os.path.dirname(os.path.abspath(__file__)) Loading @@ -38,58 +34,18 @@ See runtps --help for all options *********************************************************************** """ # Link to the folder, which contains the zip archives of virtualenv URL_VIRTUALENV = "https://codeload.github.com/pypa/virtualenv/zip/" VERSION_VIRTUALENV = "15.0.0" if sys.platform == "win32": bin_name = os.path.join("Scripts", "activate.bat") activate_env = os.path.join("Scripts", "activate_this.py") python_env = os.path.join("Scripts", "python.exe") else: bin_name = os.path.join("bin", "activate") activate_env = os.path.join("bin", "activate_this.py") python_env = os.path.join("bin", "python") def download(url, target): """Downloads the specified url to the given target.""" response = six.moves.urllib.request.urlopen(url) with open(target, "wb") as f: f.write(response.read()) return target def setup_virtualenv(target, python_bin=None): script_path = os.path.join( here, "virtualenv-%s" % VERSION_VIRTUALENV, "virtualenv.py" ) print("Downloading virtualenv {}".format(VERSION_VIRTUALENV)) zip_path = download( URL_VIRTUALENV + VERSION_VIRTUALENV, os.path.join(here, "virtualenv.zip") ) try: with zipfile.ZipFile(zip_path, "r") as f: f.extractall(here) print("Creating new virtual environment") cmd_args = [sys.executable, script_path, target] if python_bin: cmd_args.extend(["-p", python_bin]) subprocess.check_call(cmd_args) finally: try: os.remove(zip_path) except OSError: pass shutil.rmtree(os.path.dirname(script_path), ignore_errors=True) def setup_virtualenv(target): print("Creating new virtual environment:", os.path.abspath(target)) # system_site_packages=True so we have access to setuptools. venv.create(target, system_site_packages=True) def update_configfile(source, target, replacements): Loading @@ -97,7 +53,7 @@ def update_configfile(source, target, replacements): with open(source) as config: for line in config: for source_string, target_string in six.iteritems(replacements): for source_string, target_string in replacements.items(): if target_string: line = line.replace(source_string, target_string) lines.append(line) Loading Loading @@ -172,11 +128,10 @@ def main(): target = args[0] assert target setup_virtualenv(target, python_bin=options.python) setup_virtualenv(target) # Activate tps environment tps_env = os.path.join(target, activate_env) exec(open(tps_env).read(), dict(__file__=tps_env)) activate(target) # Install TPS in environment subprocess.check_call( Loading Loading @@ -217,5 +172,34 @@ def main(): print(usage_message.format(TARGET=target, BIN_NAME=bin_name)) def activate(target): # This is a lightly modified copy of `activate_this.py`, which existed when # venv was an external package, but doesn't come with the builtin venv support. old_os_path = os.environ.get("PATH", "") os.environ["PATH"] = ( os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path ) base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if sys.platform == "win32": site_packages = os.path.join(base, "Lib", "site-packages") else: site_packages = os.path.join( base, "lib", "python%s" % sys.version[:3], "site-packages" ) prev_sys_path = list(sys.path) import site site.addsitedir(site_packages) sys.real_prefix = sys.prefix sys.prefix = base # Move the added items to the front of the path: new_sys_path = [] for item in list(sys.path): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) sys.path[:0] = new_sys_path if __name__ == "__main__": main()
testing/tps/mach_commands.py +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, # You can obtain one at http://mozilla.org/MPL/2.0/. from __future__ import absolute_import, print_function import os from mach.decorators import Command, CommandArgument Loading
testing/tps/setup.py +6 −12 Original line number Diff line number Diff line Loading @@ -2,30 +2,24 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from __future__ import absolute_import from setuptools import setup, find_packages import sys version = "0.6" deps = [ "httplib2 == 0.9.2", "mozfile >= 1.2", "mozhttpd == 0.7", "mozinfo >= 0.10", "mozinstall == 1.16", "mozprocess == 0.26", "wptserve >= 3.0", "mozinfo >= 1.2", "mozinstall == 2.0.1", "mozprocess == 1.3", "mozprofile ~= 2.1", "mozrunner ~= 7.2", "mozversion == 1.5", "mozrunner ~= 8.2", "mozversion == 2.3", "PyYAML >= 4.0", ] # we only support python 2.6+ right now assert sys.version_info[0] == 2 assert sys.version_info[1] >= 6 setup( name="tps", version=version, Loading
testing/tps/tps/__init__.py +0 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ # flake8: noqa from __future__ import absolute_import from .firefoxrunner import TPSFirefoxRunner from .testrunner import TPSTestRunner