Commit adccc473 authored by ojan@chromium.org's avatar ojan@chromium.org

Fix rebaseline-o-matic logging.

We'd miss any output between the last poll and the end of
the process.

Also, print out the log lines so that you can see them when
looking at the local log.

BUG=382248

Review URL: https://codereview.chromium.org/327633003

git-svn-id: svn://svn.chromium.org/blink/trunk@176135 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 592a59eb
......@@ -877,25 +877,36 @@ class RebaselineOMatic(AbstractDeclarativeCommand):
query['newentry'] = 'on'
urllib2.urlopen("http://" + self.LOG_SERVER + "/updatelog", data=urllib.urlencode(query))
def _log_line(self, handle):
out = handle.readline().rstrip('\n')
if out:
if self._verbose:
print out
self._log_to_server(out)
return out
def _log_remaining_lines(self, handle):
out = self._log_line(handle)
while out:
out = self._log_line(handle)
def _run_logged_command(self, command):
process = self._tool.executive.popen(command, stdout=self._tool.executive.PIPE, stderr=self._tool.executive.PIPE)
while process.poll() == None:
# FIXME: This should probably batch up lines if they're available and log to the server once.
out = process.stdout.readline()
if out:
self._log_to_server(out)
self._log_line(process.stdout)
self._log_line(process.stderr)
err = process.stderr.readline()
if err:
self._log_to_server(err)
self._log_remaining_lines(process.stdout)
self._log_remaining_lines(process.stderr)
def _do_one_rebaseline(self, verbose):
def _do_one_rebaseline(self):
try:
old_branch_name = self._tool.scm().current_branch()
self._log_to_server(is_new_entry=True)
self._run_logged_command(['git', 'pull'])
rebaseline_command = [self._tool.filesystem.join(self._tool.scm().checkout_root, 'Tools', 'Scripts', 'webkit-patch'), 'auto-rebaseline']
if verbose:
if self._verbose:
rebaseline_command.append('--verbose')
self._run_logged_command(rebaseline_command)
except:
......@@ -904,6 +915,7 @@ class RebaselineOMatic(AbstractDeclarativeCommand):
self._tool.scm().checkout_branch(old_branch_name)
def execute(self, options, args, tool):
self._verbose = options.verbose
while True:
self._do_one_rebaseline(options.verbose)
self._do_one_rebaseline()
time.sleep(self.SLEEP_TIME_IN_SECONDS)
......@@ -1207,31 +1207,46 @@ class TestRebaselineOMatic(_BaseTestCase):
self._logs.append({'log': log, 'newentry': is_new_entry})
def test_run_logged_command(self):
self.command._verbose = False
self.command._log_to_server = self._mock_log_to_server
self.command._run_logged_command(['echo', 'foo'])
self.assertEqual(self.tool.executive.calls, [['echo', 'foo']])
self.assertEqual(self._logs, [{'log': 'MOCK STDOUT\n', 'newentry': False}])
self.assertEqual(self._logs, [{'log': 'MOCK STDOUT', 'newentry': False}])
def test_do_one_rebaseline(self):
self.command._verbose = False
self.command._log_to_server = self._mock_log_to_server
self.command._do_one_rebaseline(verbose=False)
oc = OutputCapture()
oc.capture_output()
self.command._do_one_rebaseline()
out, _, _ = oc.restore_output()
self.assertEqual(out, '')
self.assertEqual(self.tool.executive.calls, [
['git', 'pull'],
['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'auto-rebaseline'],
])
self.assertEqual(self._logs, [
{'log': '', 'newentry': True},
{'log': 'MOCK STDOUT\n', 'newentry': False},
{'log': 'MOCK STDOUT', 'newentry': False},
])
def test_do_one_rebaseline_verbose(self):
self.command._verbose = True
self.command._log_to_server = self._mock_log_to_server
self.command._do_one_rebaseline(verbose=True)
oc = OutputCapture()
oc.capture_output()
self.command._do_one_rebaseline()
out, _, _ = oc.restore_output()
self.assertEqual(out, 'MOCK STDOUT\n')
self.assertEqual(self.tool.executive.calls, [
['git', 'pull'],
['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'auto-rebaseline', '--verbose'],
])
self.assertEqual(self._logs, [
{'log': '', 'newentry': True},
{'log': 'MOCK STDOUT\n', 'newentry': False},
{'log': 'MOCK STDOUT', 'newentry': False},
])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment