mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 775127 - Bump mozInstall version and release to pypi and update mozbase on mozilla central. r=ahalberstadt
This commit is contained in:
parent
068326ec6d
commit
d3a3a3b3de
@ -696,8 +696,8 @@ class TestManifest(ManifestParser):
|
||||
def filter(self, values, tests):
|
||||
"""
|
||||
filter on a specific list tag, e.g.:
|
||||
run-if.os = win linux
|
||||
skip-if.os = mac
|
||||
run-if = os == win linux
|
||||
skip-if = os == mac
|
||||
"""
|
||||
|
||||
# tags:
|
||||
|
@ -13,7 +13,7 @@ import os
|
||||
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
try:
|
||||
filename = os.path.join(here, 'README.txt')
|
||||
filename = os.path.join(here, 'README.md')
|
||||
description = file(filename).read()
|
||||
except:
|
||||
description = ''
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
@ -22,7 +24,7 @@ def run_tests(raise_on_error=False, report_first=False):
|
||||
raise_on_error=raise_on_error)
|
||||
if report_first:
|
||||
doctest_args['optionflags'] = doctest.REPORT_ONLY_FIRST_FAILURE
|
||||
|
||||
|
||||
# gather tests
|
||||
directory = os.path.dirname(os.path.abspath(__file__))
|
||||
tests = [ test for test in os.listdir(directory)
|
||||
@ -74,6 +76,6 @@ def main(args=sys.argv[1:]):
|
||||
for test in sorted(results.keys()):
|
||||
result = results[test]
|
||||
print "%s: failed=%s, attempted=%s" % (test, result[0], result[1])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -17,6 +17,7 @@ import urllib
|
||||
import urlparse
|
||||
import re
|
||||
import iface
|
||||
import time
|
||||
from SocketServer import ThreadingMixIn
|
||||
|
||||
class EasyServer(ThreadingMixIn, BaseHTTPServer.HTTPServer):
|
||||
@ -63,9 +64,16 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
|
||||
docroot = os.getcwd() # current working directory at time of import
|
||||
proxy_host_dirs = False
|
||||
request_log = []
|
||||
log_requests = False
|
||||
request = None
|
||||
|
||||
def _try_handler(self, method):
|
||||
if self.log_requests:
|
||||
self.request_log.append({ 'method': method,
|
||||
'path': self.request.path,
|
||||
'time': time.time() })
|
||||
|
||||
handlers = [handler for handler in self.urlhandlers
|
||||
if handler['method'] == method]
|
||||
for handler in handlers:
|
||||
@ -181,7 +189,7 @@ class MozHttpd(object):
|
||||
"""
|
||||
|
||||
def __init__(self, host="127.0.0.1", port=8888, docroot=None,
|
||||
urlhandlers=None, proxy_host_dirs=False):
|
||||
urlhandlers=None, proxy_host_dirs=False, log_requests=False):
|
||||
self.host = host
|
||||
self.port = int(port)
|
||||
self.docroot = docroot
|
||||
@ -190,11 +198,15 @@ class MozHttpd(object):
|
||||
self.proxy_host_dirs = proxy_host_dirs
|
||||
self.httpd = None
|
||||
self.urlhandlers = urlhandlers or []
|
||||
self.log_requests = log_requests
|
||||
self.request_log = []
|
||||
|
||||
class RequestHandlerInstance(RequestHandler):
|
||||
docroot = self.docroot
|
||||
urlhandlers = self.urlhandlers
|
||||
proxy_host_dirs = self.proxy_host_dirs
|
||||
request_log = self.request_log
|
||||
log_requests = self.log_requests
|
||||
|
||||
self.handler_class = RequestHandlerInstance
|
||||
|
||||
@ -244,8 +256,6 @@ def main(args=sys.argv[1:]):
|
||||
options, args = parser.parse_args(args)
|
||||
if args:
|
||||
parser.error("mozhttpd does not take any arguments")
|
||||
parser.print_help()
|
||||
parser.exit()
|
||||
|
||||
if options.external_ip:
|
||||
host = iface.get_lan_ip()
|
||||
|
@ -11,12 +11,12 @@ try:
|
||||
except IOError:
|
||||
description = None
|
||||
|
||||
version = '0.3'
|
||||
PACKAGE_VERSION = '0.3'
|
||||
|
||||
deps = []
|
||||
|
||||
setup(name='mozhttpd',
|
||||
version=version,
|
||||
version=PACKAGE_VERSION,
|
||||
description="basic python webserver, tested with talos",
|
||||
long_description=description,
|
||||
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
@ -192,6 +194,12 @@ class ApiTest(unittest.TestCase):
|
||||
self.try_get(server_port, '')
|
||||
self.try_get(server_port, '?foo=bar')
|
||||
|
||||
class ProxyTest(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
# reset proxy opener in case it changed
|
||||
urllib2.install_opener(None)
|
||||
|
||||
def test_proxy(self):
|
||||
docroot = tempfile.mkdtemp()
|
||||
hosts = ('mozilla.com', 'mozilla.org')
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
|
@ -1,2 +1,3 @@
|
||||
[filelisting.py]
|
||||
[api.py]
|
||||
[requestlog.py]
|
||||
|
42
testing/mozbase/mozhttpd/tests/requestlog.py
Normal file
42
testing/mozbase/mozhttpd/tests/requestlog.py
Normal file
@ -0,0 +1,42 @@
|
||||
# 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/.
|
||||
|
||||
import mozhttpd
|
||||
import urllib2
|
||||
import os
|
||||
import unittest
|
||||
import time
|
||||
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
class RequestLogTest(unittest.TestCase):
|
||||
|
||||
def check_logging(self, log_requests=False):
|
||||
filelist = os.listdir(here)
|
||||
|
||||
httpd = mozhttpd.MozHttpd(port=0, docroot=here, log_requests=log_requests)
|
||||
httpd.start(block=False)
|
||||
url = "http://%s:%s/" % ('127.0.0.1', httpd.httpd.server_port)
|
||||
f = urllib2.urlopen(url)
|
||||
data = f.read()
|
||||
|
||||
return httpd.request_log
|
||||
|
||||
def test_logging_enabled(self):
|
||||
request_log = self.check_logging(log_requests=True)
|
||||
|
||||
self.assertEqual(len(request_log), 1)
|
||||
|
||||
log_entry = request_log[0]
|
||||
self.assertEqual(log_entry['method'], 'GET')
|
||||
self.assertEqual(log_entry['path'], '/')
|
||||
self.assertEqual(type(log_entry['time']), float)
|
||||
|
||||
def test_logging_disabled(self):
|
||||
request_log = self.check_logging(log_requests=False)
|
||||
|
||||
self.assertEqual(len(request_log), 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -6,7 +6,7 @@
|
||||
import os
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
version = '0.3.3'
|
||||
PACKAGE_VERSION = '0.3.3'
|
||||
|
||||
# get documentation from the README
|
||||
try:
|
||||
@ -23,7 +23,7 @@ except ImportError:
|
||||
deps = ['simplejson']
|
||||
|
||||
setup(name='mozinfo',
|
||||
version=version,
|
||||
version=PACKAGE_VERSION,
|
||||
description="file for interface to transform introspected system information to a format pallatable to Mozilla",
|
||||
long_description=description,
|
||||
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
|
@ -2,7 +2,7 @@
|
||||
python package for installing and uninstalling Mozilla applications on
|
||||
various platforms.
|
||||
|
||||
For example, depending on the platform, Firefox can be distributed as a
|
||||
For example, depending on the platform, Firefox can be distributed as a
|
||||
zip, tar.bz2, exe, or dmg file or cloned from a repository. Mozinstall takes
|
||||
the hassle out of extracting and/or running these files and for convenience
|
||||
returns the full path to the install directory. In the case that mozinstall
|
||||
|
@ -218,23 +218,20 @@ def _extract(src, dest):
|
||||
"""
|
||||
if zipfile.is_zipfile(src):
|
||||
bundle = zipfile.ZipFile(src)
|
||||
namelist = bundle.namelist()
|
||||
|
||||
if hasattr(bundle, 'extractall'):
|
||||
# zipfile.extractall doesn't exist in Python 2.5
|
||||
bundle.extractall(path=dest)
|
||||
else:
|
||||
for name in namelist:
|
||||
filename = os.path.realpath(os.path.join(dest, name))
|
||||
if name.endswith('/'):
|
||||
os.makedirs(filename)
|
||||
else:
|
||||
path = os.path.dirname(filename)
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
dest = open(filename, 'wb')
|
||||
dest.write(bundle.read(name))
|
||||
dest.close()
|
||||
# FIXME: replace with zip.extractall() when we require python 2.6
|
||||
namelist = bundle.namelist()
|
||||
for name in bundle.namelist():
|
||||
filename = os.path.realpath(os.path.join(dest, name))
|
||||
if name.endswith('/'):
|
||||
os.makedirs(filename)
|
||||
else:
|
||||
path = os.path.dirname(filename)
|
||||
if not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
_dest = open(filename, 'wb')
|
||||
_dest.write(bundle.read(name))
|
||||
_dest.close()
|
||||
|
||||
elif tarfile.is_tarfile(src):
|
||||
bundle = tarfile.open(src)
|
||||
|
@ -11,12 +11,12 @@ try:
|
||||
except IOError:
|
||||
description = None
|
||||
|
||||
version = '1.1'
|
||||
PACKAGE_VERSION = '1.2'
|
||||
|
||||
deps = ['mozinfo==0.3.3']
|
||||
|
||||
setup(name='mozInstall',
|
||||
version=version,
|
||||
version=PACKAGE_VERSION,
|
||||
description="This is a utility package for installing and uninstalling "
|
||||
"Mozilla applications on various platforms.",
|
||||
long_description=description,
|
||||
|
@ -1,12 +1,12 @@
|
||||
[Mozlog](https://github.com/mozilla/mozbase/tree/master/mozlog)
|
||||
is a python package intended to simplify and standardize logs in the Mozilla universe.
|
||||
It wraps around python's [logging](http://docs.python.org/library/logging.html)
|
||||
is a python package intended to simplify and standardize logs in the Mozilla universe.
|
||||
It wraps around python's [logging](http://docs.python.org/library/logging.html)
|
||||
module and adds some additional functionality.
|
||||
|
||||
# Usage
|
||||
|
||||
Import mozlog instead of [logging](http://docs.python.org/library/logging.html)
|
||||
(all functionality in the logging module is also available from the mozlog module).
|
||||
Import mozlog instead of [logging](http://docs.python.org/library/logging.html)
|
||||
(all functionality in the logging module is also available from the mozlog module).
|
||||
To get a logger, call mozlog.getLogger passing in a name and the path to a log file.
|
||||
If no log file is specified, the logger will log to stdout.
|
||||
|
||||
|
@ -14,14 +14,18 @@ import time
|
||||
import traceback
|
||||
from Queue import Queue
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
__all__ = ['ProcessHandlerMixin', 'ProcessHandler']
|
||||
|
||||
# Set the MOZPROCESS_DEBUG environment variable to 1 to see some debugging output
|
||||
MOZPROCESS_DEBUG = os.getenv("MOZPROCESS_DEBUG")
|
||||
|
||||
if mozinfo.isWin:
|
||||
import ctypes, ctypes.wintypes, msvcrt
|
||||
from ctypes import sizeof, addressof, c_ulong, byref, POINTER, WinError
|
||||
from ctypes import sizeof, addressof, c_ulong, byref, POINTER, WinError, c_longlong
|
||||
import winprocess
|
||||
from qijo import JobObjectAssociateCompletionPortInformation, JOBOBJECT_ASSOCIATE_COMPLETION_PORT
|
||||
from qijo import JobObjectAssociateCompletionPortInformation,\
|
||||
JOBOBJECT_ASSOCIATE_COMPLETION_PORT, JobObjectExtendedLimitInformation,\
|
||||
JOBOBJECT_BASIC_LIMIT_INFORMATION, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, IO_COUNTERS
|
||||
|
||||
class ProcessHandlerMixin(object):
|
||||
"""Class which represents a process to be executed."""
|
||||
@ -211,6 +215,35 @@ class ProcessHandlerMixin(object):
|
||||
sizeof(joacp)
|
||||
)
|
||||
|
||||
# Allow subprocesses to break away from us - necessary for
|
||||
# flash with protected mode
|
||||
jbli = JOBOBJECT_BASIC_LIMIT_INFORMATION(
|
||||
c_longlong(0), # per process time limit (ignored)
|
||||
c_longlong(0), # per job user time limit (ignored)
|
||||
winprocess.JOB_OBJECT_LIMIT_BREAKAWAY_OK,
|
||||
0, # min working set (ignored)
|
||||
0, # max working set (ignored)
|
||||
0, # active process limit (ignored)
|
||||
None, # affinity (ignored)
|
||||
0, # Priority class (ignored)
|
||||
0, # Scheduling class (ignored)
|
||||
)
|
||||
|
||||
iocntr = IO_COUNTERS()
|
||||
jeli = JOBOBJECT_EXTENDED_LIMIT_INFORMATION(
|
||||
jbli, # basic limit info struct
|
||||
iocntr, # io_counters (ignored)
|
||||
0, # process mem limit (ignored)
|
||||
0, # job mem limit (ignored)
|
||||
0, # peak process limit (ignored)
|
||||
0) # peak job limit (ignored)
|
||||
|
||||
winprocess.SetInformationJobObject(self._job,
|
||||
JobObjectExtendedLimitInformation,
|
||||
addressof(jeli),
|
||||
sizeof(jeli)
|
||||
)
|
||||
|
||||
# Assign the job object to the process
|
||||
winprocess.AssignProcessToJobObject(self._job, int(hp))
|
||||
|
||||
@ -255,6 +288,9 @@ falling back to not using job objects for managing child processes"""
|
||||
self._spawned_procs = {}
|
||||
countdowntokill = 0
|
||||
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC Self.pid value is: %s" % self.pid
|
||||
|
||||
while True:
|
||||
msgid = c_ulong(0)
|
||||
compkey = c_ulong(0)
|
||||
@ -296,6 +332,8 @@ falling back to not using job objects for managing child processes"""
|
||||
break
|
||||
|
||||
if compkey.value == winprocess.COMPKEY_TERMINATE.value:
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC compkeyterminate detected"
|
||||
# Then we're done
|
||||
break
|
||||
|
||||
@ -304,6 +342,8 @@ falling back to not using job objects for managing child processes"""
|
||||
if msgid.value == winprocess.JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO:
|
||||
# No processes left, time to shut down
|
||||
# Signal anyone waiting on us that it is safe to shut down
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC job object msg active processes zero"
|
||||
self._process_events.put({self.pid: 'FINISHED'})
|
||||
break
|
||||
elif msgid.value == winprocess.JOB_OBJECT_MSG_NEW_PROCESS:
|
||||
@ -312,7 +352,11 @@ falling back to not using job objects for managing child processes"""
|
||||
# without killing everything.
|
||||
if pid.value != self.pid:
|
||||
self._spawned_procs[pid.value] = 1
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC new process detected with pid value: %s" % pid.value
|
||||
elif msgid.value == winprocess.JOB_OBJECT_MSG_EXIT_PROCESS:
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC process id %s exited normally" % pid.value
|
||||
# One process exited normally
|
||||
if pid.value == self.pid and len(self._spawned_procs) > 0:
|
||||
# Parent process dying, start countdown timer
|
||||
@ -322,6 +366,8 @@ falling back to not using job objects for managing child processes"""
|
||||
del(self._spawned_procs[pid.value])
|
||||
elif msgid.value == winprocess.JOB_OBJECT_MSG_ABNORMAL_EXIT_PROCESS:
|
||||
# One process existed abnormally
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC process id %s existed abnormally" % pid.value
|
||||
if pid.value == self.pid and len(self._spawned_procs) > 0:
|
||||
# Parent process dying, start countdown timer
|
||||
countdowntokill = datetime.now()
|
||||
@ -330,6 +376,8 @@ falling back to not using job objects for managing child processes"""
|
||||
del self._spawned_procs[pid.value]
|
||||
else:
|
||||
# We don't care about anything else
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC We got a message %s" % msgid.value
|
||||
pass
|
||||
|
||||
def _wait(self):
|
||||
@ -377,6 +425,8 @@ falling back to not using job objects for managing child processes"""
|
||||
# Not managing with job objects, so all we can reasonably do
|
||||
# is call waitforsingleobject and hope for the best
|
||||
|
||||
if MOZPROCESS_DEBUG:
|
||||
print "DBG::MOZPROC NOT USING JOB OBJECTS!!!"
|
||||
# First, make sure we have not already ended
|
||||
if self.returncode != winprocess.STILL_ACTIVE:
|
||||
self._cleanup()
|
||||
|
@ -52,29 +52,3 @@ def kill_pid(pid):
|
||||
if process:
|
||||
windll.kernel32.TerminateProcess(process, 0)
|
||||
windll.kernel32.CloseHandle(process)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
# This test just opens a new notepad instance and kills it.
|
||||
|
||||
name = 'notepad'
|
||||
|
||||
old_pids = set(get_pids(name))
|
||||
subprocess.Popen([name])
|
||||
time.sleep(0.25)
|
||||
new_pids = set(get_pids(name)).difference(old_pids)
|
||||
|
||||
if len(new_pids) != 1:
|
||||
raise Exception('%s was not opened or get_pids() is '
|
||||
'malfunctioning' % name)
|
||||
|
||||
kill_pid(tuple(new_pids)[0])
|
||||
|
||||
newest_pids = set(get_pids(name)).difference(old_pids)
|
||||
|
||||
if len(newest_pids) != 0:
|
||||
raise Exception('kill_pid() is malfunctioning')
|
||||
|
||||
print "Test passed."
|
||||
|
@ -5,7 +5,7 @@
|
||||
import os
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
PACKAGE_VERSION = '0.3'
|
||||
PACKAGE_VERSION = '0.4'
|
||||
|
||||
# take description from README
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
@ -20,6 +22,9 @@ def make_proclaunch(aDir):
|
||||
Returns:
|
||||
the path to the proclaunch executable that is generated
|
||||
"""
|
||||
# Ideally make should take care of this, but since it doesn't - on windows,
|
||||
# anyway, let's just call out both targets explicitly.
|
||||
p = subprocess.call(["make", "-C", "iniparser"], cwd=aDir)
|
||||
p = subprocess.call(["make"], cwd=aDir)
|
||||
if sys.platform == "win32":
|
||||
exepath = os.path.join(aDir, "proclaunch.exe")
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
@ -25,6 +27,9 @@ def make_proclaunch(aDir):
|
||||
Returns:
|
||||
the path to the proclaunch executable that is generated
|
||||
"""
|
||||
# Ideally make should take care of this, but since it doesn't - on windows,
|
||||
# anyway, let's just call out both targets explicitly.
|
||||
p = subprocess.call(["make", "-C", "iniparser"], cwd=aDir)
|
||||
p = subprocess.call(["make"], cwd=aDir)
|
||||
if sys.platform == "win32":
|
||||
exepath = os.path.join(aDir, "proclaunch.exe")
|
||||
|
@ -208,6 +208,3 @@ class Preferences(object):
|
||||
|
||||
if isinstance(_file, basestring):
|
||||
f.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
@ -5,7 +5,9 @@
|
||||
__all__ = ['Profile', 'FirefoxProfile', 'ThunderbirdProfile']
|
||||
|
||||
import os
|
||||
import time
|
||||
import tempfile
|
||||
import uuid
|
||||
from addons import AddonManager
|
||||
from permissions import Permissions
|
||||
from shutil import rmtree
|
||||
@ -36,7 +38,8 @@ class Profile(object):
|
||||
self.written_prefs = set()
|
||||
|
||||
# our magic markers
|
||||
self.delimeters = ('#MozRunner Prefs Start', '#MozRunner Prefs End')
|
||||
nonce = '%s %s' % (str(time.time()), uuid.uuid4())
|
||||
self.delimeters = ('#MozRunner Prefs Start %s' % nonce,'#MozRunner Prefs End %s' % nonce)
|
||||
|
||||
# Handle profile creation
|
||||
self.create_new = not profile
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
import sys
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
version = '0.4'
|
||||
PACKAGE_VERSION = '0.4'
|
||||
|
||||
# we only support python 2 right now
|
||||
assert sys.version_info[0] == 2
|
||||
@ -31,7 +31,7 @@ except (OSError, IOError):
|
||||
description = ''
|
||||
|
||||
setup(name='mozprofile',
|
||||
version=version,
|
||||
version=PACKAGE_VERSION,
|
||||
description="Handling of Mozilla Gecko based application profiles",
|
||||
long_description=description,
|
||||
classifiers=['Environment :: Console',
|
||||
|
@ -3,3 +3,4 @@
|
||||
[test_preferences.py]
|
||||
[permissions.py]
|
||||
[bug758250.py]
|
||||
[test_nonce.py]
|
||||
|
47
testing/mozbase/mozprofile/tests/test_nonce.py
Normal file
47
testing/mozbase/mozprofile/tests/test_nonce.py
Normal file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
test nonce in prefs delimeters
|
||||
see https://bugzilla.mozilla.org/show_bug.cgi?id=722804
|
||||
"""
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
from mozprofile.prefs import Preferences
|
||||
from mozprofile.profile import Profile
|
||||
|
||||
class PreferencesNonceTest(unittest.TestCase):
|
||||
|
||||
def test_nonce(self):
|
||||
|
||||
# make a profile with one preference
|
||||
path = tempfile.mktemp()
|
||||
profile = Profile(path,
|
||||
preferences={'foo': 'bar'},
|
||||
restore=False)
|
||||
user_js = os.path.join(profile.profile, 'user.js')
|
||||
self.assertTrue(os.path.exists(user_js))
|
||||
|
||||
# ensure the preference is correct
|
||||
prefs = Preferences.read_prefs(user_js)
|
||||
self.assertEqual(dict(prefs), {'foo': 'bar'})
|
||||
|
||||
del profile
|
||||
|
||||
# augment the profile with a second preference
|
||||
profile = Profile(path,
|
||||
preferences={'fleem': 'baz'},
|
||||
restore=True)
|
||||
prefs = Preferences.read_prefs(user_js)
|
||||
self.assertEqual(dict(prefs), {'foo': 'bar', 'fleem': 'baz'})
|
||||
|
||||
# cleanup the profile;
|
||||
# this should remove the new preferences but not the old
|
||||
profile.cleanup()
|
||||
prefs = Preferences.read_prefs(user_js)
|
||||
self.assertEqual(dict(prefs), {'foo': 'bar'})
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -85,7 +85,7 @@ browser.startup.homepage = http://github.com/
|
||||
|
||||
# cleanup
|
||||
os.remove(name)
|
||||
|
||||
|
||||
def test_reset_should_remove_added_prefs(self):
|
||||
"""Check that when we call reset the items we expect are updated"""
|
||||
|
||||
@ -103,8 +103,10 @@ browser.startup.homepage = http://github.com/
|
||||
profile.set_preferences(prefs1)
|
||||
self.assertEqual(prefs1, Preferences.read_prefs(prefs_file))
|
||||
lines = file(prefs_file).read().strip().splitlines()
|
||||
self.assertTrue('#MozRunner Prefs Start' in lines)
|
||||
self.assertTrue('#MozRunner Prefs End' in lines)
|
||||
self.assertTrue(bool([line for line in lines
|
||||
if line.startswith('#MozRunner Prefs Start')]))
|
||||
self.assertTrue(bool([line for line in lines
|
||||
if line.startswith('#MozRunner Prefs End')]))
|
||||
|
||||
profile.reset()
|
||||
self.assertNotEqual(prefs1, \
|
||||
@ -129,8 +131,10 @@ browser.startup.homepage = http://github.com/
|
||||
profile.set_preferences(prefs1)
|
||||
self.assertEqual(prefs1, Preferences.read_prefs(prefs_file))
|
||||
lines = file(prefs_file).read().strip().splitlines()
|
||||
self.assertTrue('#MozRunner Prefs Start' in lines)
|
||||
self.assertTrue('#MozRunner Prefs End' in lines)
|
||||
self.assertTrue(bool([line for line in lines
|
||||
if line.startswith('#MozRunner Prefs Start')]))
|
||||
self.assertTrue(bool([line for line in lines
|
||||
if line.startswith('#MozRunner Prefs End')]))
|
||||
|
||||
# add some more preferences
|
||||
prefs2 = [("zoom.maxPercent", 300),
|
||||
@ -138,8 +142,10 @@ browser.startup.homepage = http://github.com/
|
||||
profile.set_preferences(prefs2)
|
||||
self.assertEqual(prefs1 + prefs2, Preferences.read_prefs(prefs_file))
|
||||
lines = file(prefs_file).read().strip().splitlines()
|
||||
self.assertTrue(lines.count('#MozRunner Prefs Start') == 2)
|
||||
self.assertTrue(lines.count('#MozRunner Prefs End') == 2)
|
||||
self.assertTrue(len([line for line in lines
|
||||
if line.startswith('#MozRunner Prefs Start')]) == 2)
|
||||
self.assertTrue(len([line for line in lines
|
||||
if line.startswith('#MozRunner Prefs End')]) == 2)
|
||||
|
||||
# now clean it up
|
||||
profile.clean_preferences()
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
|
@ -7,7 +7,7 @@ import sys
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
PACKAGE_NAME = "mozrunner"
|
||||
PACKAGE_VERSION = '5.7'
|
||||
PACKAGE_VERSION = '5.8'
|
||||
|
||||
desc = """Reliable start/stop/configuration of Mozilla Applications (Firefox, Thunderbird, etc.)"""
|
||||
# take description from README
|
||||
@ -18,7 +18,7 @@ except (OSError, IOError):
|
||||
description = ''
|
||||
|
||||
deps = ['mozinfo == 0.3.3',
|
||||
'mozprocess == 0.3',
|
||||
'mozprocess == 0.4',
|
||||
'mozprofile == 0.4',
|
||||
]
|
||||
|
||||
|
@ -40,30 +40,21 @@ def cycle_check(order, dependencies):
|
||||
for d in deps:
|
||||
assert index > order_dict[d], "Cyclic dependencies detected"
|
||||
|
||||
def dependencies(directory):
|
||||
"""
|
||||
get the dependencies of a package directory containing a setup.py
|
||||
returns the package name and the list of dependencies
|
||||
"""
|
||||
def info(directory):
|
||||
"get the package setup.py information"
|
||||
|
||||
assert os.path.exists(os.path.join(directory, 'setup.py'))
|
||||
|
||||
# setup the egg info
|
||||
call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=PIPE)
|
||||
|
||||
# get the .egg-info directory
|
||||
egg_info = [i for i in os.listdir(directory)
|
||||
if i.endswith('.egg-info')]
|
||||
egg_info = [entry for entry in os.listdir(directory)
|
||||
if entry.endswith('.egg-info')]
|
||||
assert len(egg_info) == 1, 'Expected one .egg-info directory in %s, got: %s' % (directory, egg_info)
|
||||
egg_info = os.path.join(directory, egg_info[0])
|
||||
assert os.path.isdir(egg_info), "%s is not a directory" % egg_info
|
||||
|
||||
# read the dependencies
|
||||
requires = os.path.join(egg_info, 'requires.txt')
|
||||
if os.path.exists(requires):
|
||||
dependencies = [i.strip() for i in file(requires).readlines() if i.strip()]
|
||||
else:
|
||||
dependencies = []
|
||||
|
||||
# read the package information
|
||||
pkg_info = os.path.join(egg_info, 'PKG-INFO')
|
||||
info_dict = {}
|
||||
@ -74,20 +65,43 @@ def dependencies(directory):
|
||||
key, value = [i.strip() for i in line.split(':', 1)]
|
||||
info_dict[key] = value
|
||||
|
||||
return info_dict
|
||||
|
||||
def get_dependencies(directory):
|
||||
"returns the package name and dependencies given a package directory"
|
||||
|
||||
# get the package metadata
|
||||
info_dict = info(directory)
|
||||
|
||||
# get the .egg-info directory
|
||||
egg_info = [entry for entry in os.listdir(directory)
|
||||
if entry.endswith('.egg-info')][0]
|
||||
|
||||
# read the dependencies
|
||||
requires = os.path.join(directory, egg_info, 'requires.txt')
|
||||
if os.path.exists(requires):
|
||||
dependencies = [line.strip()
|
||||
for line in file(requires).readlines()
|
||||
if line.strip()]
|
||||
else:
|
||||
dependencies = []
|
||||
|
||||
# return the information
|
||||
return info_dict['Name'], dependencies
|
||||
|
||||
def sanitize_dependency(dep):
|
||||
"""
|
||||
remove version numbers from deps
|
||||
"""
|
||||
def dependency_info(dep):
|
||||
"return dictionary of dependency information from a dependency string"
|
||||
retval = dict(Name=None, Type=None, Version=None)
|
||||
for joiner in ('==', '<=', '>='):
|
||||
if joiner in dep:
|
||||
dep = dep.split(joiner, 1)[0].strip()
|
||||
return dep # XXX only one joiner allowed right now
|
||||
return dep
|
||||
|
||||
retval['Type'] = joiner
|
||||
name, version = [i.strip() for i in dep.split(joiner, 1)]
|
||||
retval['Name'] = name
|
||||
retval['Version'] = version
|
||||
break
|
||||
else:
|
||||
retval['name'] = dep.strip()
|
||||
return retval
|
||||
|
||||
def unroll_dependencies(dependencies):
|
||||
"""
|
||||
@ -144,7 +158,7 @@ def main(args=sys.argv[1:]):
|
||||
if options.list_dependencies:
|
||||
# list the package dependencies
|
||||
for package in packages:
|
||||
print '%s: %s' % dependencies(os.path.join(here, package))
|
||||
print '%s: %s' % get_dependencies(os.path.join(here, package))
|
||||
parser.exit()
|
||||
|
||||
# gather dependencies
|
||||
@ -154,13 +168,13 @@ def main(args=sys.argv[1:]):
|
||||
mapping = {} # mapping from subdir name to package name
|
||||
# core dependencies
|
||||
for package in packages:
|
||||
key, value = dependencies(os.path.join(here, package))
|
||||
deps[key] = [sanitize_dependency(dep) for dep in value]
|
||||
key, value = get_dependencies(os.path.join(here, package))
|
||||
deps[key] = [dependency_info(dep)['Name'] for dep in value]
|
||||
mapping[package] = key
|
||||
|
||||
# keep track of all dependencies for non-mozbase packages
|
||||
for dep in value:
|
||||
alldeps[sanitize_dependency(dep)] = ''.join(dep.split())
|
||||
alldeps[dependency_info(dep)['Name']] = ''.join(dep.split())
|
||||
|
||||
# indirect dependencies
|
||||
flag = True
|
||||
@ -169,7 +183,7 @@ def main(args=sys.argv[1:]):
|
||||
for value in deps.values():
|
||||
for dep in value:
|
||||
if dep in all_packages and dep not in deps:
|
||||
key, value = dependencies(os.path.join(here, dep))
|
||||
key, value = get_dependencies(os.path.join(here, dep))
|
||||
deps[key] = [sanitize_dependency(dep) for dep in value]
|
||||
|
||||
for dep in value:
|
||||
@ -184,7 +198,7 @@ def main(args=sys.argv[1:]):
|
||||
for package in all_packages:
|
||||
if package in mapping:
|
||||
continue
|
||||
key, value = dependencies(os.path.join(here, package))
|
||||
key, value = get_dependencies(os.path.join(here, package))
|
||||
mapping[package] = key
|
||||
|
||||
# unroll dependencies
|
||||
|
@ -1,3 +1,7 @@
|
||||
# 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/.
|
||||
|
||||
# mozbase test manifest, in the format of
|
||||
# https://github.com/mozilla/mozbase/blob/master/manifestdestiny/README.txt
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
|
||||
"""
|
||||
run mozbase tests from a manifest,
|
||||
by default https://github.com/mozilla/mozbase/blob/master/test-manifest.ini
|
||||
|
Loading…
Reference in New Issue
Block a user