Skip to content

Commit

Permalink
Move Adapter.pre_launch() call to Session.run()
Browse files Browse the repository at this point in the history
  • Loading branch information
tysmith committed Jun 26, 2019
1 parent 6e6e8d7 commit 8e94051
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions grizzly/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def generate_testcase(self):

def launch_target(self):
assert self.target.closed
self.adapter.pre_launch()
launch_timeouts = 0
while True:
try:
Expand Down Expand Up @@ -166,6 +165,7 @@ def run(self, iteration_limit=None):
self.status.iteration += 1

if self.target.closed:
self.adapter.pre_launch()
self.launch_target()
self.target.step()

Expand All @@ -192,14 +192,13 @@ def run(self, iteration_limit=None):
log.debug("calling self.adapter.on_served()")
self.adapter.on_served(current_test, files_served)


# check for results and report as necessary
self.check_results(not files_served, server_status == sapphire.SERVED_TIMEOUT)

# warn about large browser logs
self.status.log_size = self.target.log_size()
if self.status.log_size > self.TARGET_LOG_SIZE_WARN:
log.warning("Large browser logs: %dMBs", (self.status.log_size/0x100000))
log.warning("Large browser logs: %dMBs", (self.status.log_size / 0x100000))

if self.coverage:
self.target.dump_coverage()
Expand Down
4 changes: 2 additions & 2 deletions grizzly/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ def save_logs(self, result_logs, meta=True):
fake_target = FakeTarget()
session = Session(fake_adapter, False, [], fake_iomgr, None, fake_target)
session.server = fake_server
fake_adapter.pre_launch.assert_not_called()
session.launch_target()
assert not fake_target.closed
fake_adapter.pre_launch.assert_called_once()

fake_target = FakeTarget(launch_raise=BrowserTerminatedError)
fake_reporter = mocker.Mock(spec=Reporter)
Expand Down Expand Up @@ -254,9 +252,11 @@ def fake_serve_testcase(*_a, **_kw):
session.server.serve_testcase = fake_serve_testcase
fake_adapter.on_served.assert_not_called()
fake_adapter.on_timeout.assert_not_called()
fake_adapter.pre_launch.assert_not_called()
session.run(10)
fake_adapter.on_served.assert_called()
fake_adapter.on_timeout.assert_called()
fake_adapter.pre_launch.assert_called()
session.close()

fake_server.assert_called_once()
Expand Down

0 comments on commit 8e94051

Please sign in to comment.