Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge branch 'parser' of git://github.com/whimboo/mozmill into whimbood
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Oct 27, 2009
2 parents 022c9a3 + 72bcf1e commit 3231c5d
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions mozmill/__init__.py
Expand Up @@ -81,12 +81,8 @@ def __call__(self, eName, obj):
self.cases[eName] = self.default(eName)
self.cases[eName](obj)

class Persisted(object):
''' Class used to share data between Python and Javascript '''

def reset(self):
for entry in self.__dict__:
del entry
class TestsFailedException(Exception):
pass

class MozMill(object):

Expand All @@ -96,14 +92,14 @@ def __init__(self, runner_class=mozrunner.FirefoxRunner,
self.profile_class = profile_class
self.jsbridge_port = jsbridge_port

self.persisted = Persisted()
self.endRunnerCalled = False

self.passes = [] ; self.fails = [] ; self.skipped = []
self.alltests = []

self.listeners = []
self.persisted = {}
self.endRunnerCalled = False

self.global_listeners = []
self.listeners = []
self.add_listener(self.persist_listener, eventType="mozmill.persist")
self.add_listener(self.endTest_listener, eventType='mozmill.endTest')
self.add_listener(self.endRunner_listener, eventType='mozmill.endRunner')
Expand All @@ -115,7 +111,7 @@ def add_global_listener(self, callback):
self.global_listeners.append(callback)

def persist_listener(self, obj):
self.persisted.__dict__ = obj
self.persisted = obj

def create_network(self):
self.back_channel, self.bridge = jsbridge.wait_and_create_network("127.0.0.1",
Expand All @@ -136,8 +132,8 @@ def start(self, profile=None, runner=None):
self.profile = profile;
self.runner = runner
self.runner.start()

self.endRunnerCalled = False

self.create_network()

def run_tests(self, test, report=False, sleeptime = 4):
Expand All @@ -147,7 +143,7 @@ def run_tests(self, test, report=False, sleeptime = 4):
starttime = datetime.utcnow().isoformat()

''' transfer persisted data '''
frame.persisted = self.persisted.__dict__
frame.persisted = self.persisted

if os.path.isdir(test):
frame.runTestDirectory(test)
Expand Down Expand Up @@ -237,9 +233,10 @@ def start(self, runner=None, profile=None):
self.profile = profile;
self.runner = runner

self.endRunnerCalled = False

def start_runner(self):
self.runner.start()
self.endRunnerCalled = False

self.create_network()
frame = jsbridge.JSObject(self.bridge,
Expand Down Expand Up @@ -294,7 +291,7 @@ def run_dir(self, test_dir, report=False, sleeptime=4):
self.endRunnerCalled = False
sleep(sleeptime)

frame.persisted = self.persisted.__dict__
frame.persisted = self.persisted
frame.runTestFile(test)
while not self.endRunnerCalled:
sleep(.25)
Expand Down Expand Up @@ -371,7 +368,7 @@ def get_profile(self, *args, **kwargs):
profile.install_plugin(extension_path)
return profile

def run(self):
def _run(self):
runner = self.create_runner()
if '-foreground' not in runner.cmdargs:
runner.cmdargs.append('-foreground')
Expand Down Expand Up @@ -412,6 +409,10 @@ def run(self):

if self.mozmill.runner:
self.mozmill.stop()
if len(self.mozmill.fails) > 0:
if self.mozmill.runner is not None:
self.mozmill.runner.profile.cleanup()
raise TestsFailedException()
else:
if self.options.shell:
self.start_shell(runner)
Expand All @@ -426,6 +427,12 @@ def run(self):
if self.mozmill.runner is not None:
self.mozmill.runner.profile.cleanup()

def run(self):
try:
self._run()
except TestsFailedException, e:
sys.exit(1)

class RestartCLI(CLI):
mozmill_class = MozMillRestart

Expand Down

0 comments on commit 3231c5d

Please sign in to comment.