提交 1d1c7d22 编写于 作者: C Cleber Rosa

Output record: also record the combined stdout+stderr output

Some tests that rely on output check may also rely on the combined
generated output (stdout+stderr).  The first step is to record that
in the same order it was generated.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 a2d17ab4
......@@ -213,6 +213,7 @@ class Test(unittest.TestCase):
self._stdout_file = os.path.join(self.logdir, 'stdout')
self._stderr_file = os.path.join(self.logdir, 'stderr')
self._output_file = os.path.join(self.logdir, 'output')
self._logging_handlers = {}
self.__outputdir = utils_path.init_dir(self.logdir, 'data')
......@@ -526,6 +527,14 @@ class Test(unittest.TestCase):
formatter,
self._ssh_logfile)
# combined output logging
self._register_log_file_handler(log_test_stdout,
stream_formatter,
self._output_file)
self._register_log_file_handler(log_test_stderr,
stream_formatter,
self._output_file)
if isinstance(sys.stdout, output.LoggingFile):
sys.stdout.add_logger(log_test_stdout)
if isinstance(sys.stderr, output.LoggingFile):
......
......@@ -150,6 +150,9 @@ class OutputTest(unittest.TestCase):
open(os.path.join(testdir, "stdout")).read())
self.assertEqual("test_stderr\n",
open(os.path.join(testdir, "stderr")).read())
self.assertEqual("test_print\ntest_stdout\ntest_stderr\n"
"test_process\n",
open(os.path.join(testdir, "output")).read())
def tearDown(self):
shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册