Merge "Make SolarTransportResult output contain both outs"
This commit is contained in:
commit
67fbf11bbb
@ -49,11 +49,7 @@ class BaseHandler(object):
|
||||
if not result.success:
|
||||
message = 'CMD %r failed RC %s ERR %s' % (cmd, rc, err)
|
||||
log.error(message)
|
||||
# TODO: https://bugs.launchpad.net/solar/+bug/1544537
|
||||
e_cnt = "stdout:\n{}\n{}\nstderr:\n{}".format(result.stdout,
|
||||
'=' * 80,
|
||||
result.stderr)
|
||||
raise errors.SolarError(e_cnt)
|
||||
raise errors.SolarError(result.output)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
@ -81,10 +81,9 @@ class SolarTransportResult(object):
|
||||
def output(self):
|
||||
if self.success:
|
||||
return self.stdout
|
||||
msg = self.stderr
|
||||
if not msg:
|
||||
msg = self.stdout
|
||||
return msg
|
||||
|
||||
return "stdout:\n{}\n{}\nstderr:\n{}".format(self.stdout, '=' * 80,
|
||||
self.stderr)
|
||||
|
||||
@classmethod
|
||||
def from_tuple(cls, return_code, stdout, stderr):
|
||||
|
33
solar/test/test_handler.py
Normal file
33
solar/test/test_handler.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright 2016 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pytest
|
||||
|
||||
from solar.core.handlers.base import BaseHandler
|
||||
from solar.core.transports.base import SolarTransportResult
|
||||
from solar.errors import SolarError
|
||||
|
||||
|
||||
def test_verify_run_raises_stdout_and_stderr():
|
||||
handler = BaseHandler(None)
|
||||
|
||||
result = SolarTransportResult()
|
||||
result.stdout = 'stdout'
|
||||
result.stderr = 'stderr'
|
||||
result.return_code = 1
|
||||
|
||||
with pytest.raises(SolarError) as excinfo:
|
||||
handler.verify_run_result('', result)
|
||||
assert result.stdout in excinfo.value.message
|
||||
assert result.stderr in excinfo.value.message
|
Loading…
x
Reference in New Issue
Block a user