# Path: elbepack/shellhelper.py
# def command_out(cmd, stdin=None, output=PIPE, env_add=None):
#     """command_out() - Execute cmd in a shell.
# 
#     Returns a tuple with the exitcode and the output of cmd.
# 
#     --
# 
#     >>> command_out("true")
#     (0, '')
# 
#     >>> command_out("$TRUE && true", env_add={"TRUE":"true"})
#     (0, '')
# 
#     >>> command_out("cat -", stdin=b"ELBE")
#     (0, 'ELBE')
# 
#     >>> command_out("2>&1 cat -", stdin=b"ELBE")
#     (0, 'ELBE')
# 
#     >>> command_out("2>&1 cat -", stdin="ELBE")
#     (0, 'ELBE')
# 
#     >>> command_out("false")
#     (1, '')
# 
#     """
#     new_env = os.environ.copy()
#     if env_add:
#         new_env.update(env_add)
# 
#     if isinstance(stdin, str):
#         stdin = stdin.encode()
# 
#     if stdin is None:
#         p = Popen(cmd, shell=True,
#                   stdout=output, stderr=STDOUT, env=new_env)
#         out, _ = p.communicate()
#     else:
#         p = Popen(cmd, shell=True,
#                   stdout=output, stderr=STDOUT, stdin=PIPE, env=new_env)
#         out, _ = p.communicate(input=stdin)
# 
#     out = TextIOWrapper(BytesIO(out), encoding='utf-8', errors='replace').read()
# 
#     return p.returncode, out


import enum
import optparse
import os
import re
import unittest
import warnings
import junit_xml as junit
from elbepack.shellhelper import command_out
    def __init__(self):
        super().__init__()
        self.cases = []
        self.current_case = None

    def startTest(self, test):
        self.current_case = junit.TestCase(name=str(test))
        self.cases.append(self.current_case)
        super().startTest(test)

    def addError(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
           returned by sys.exc_info().
        """

        message = str(err[1])
        output = self._exc_info_to_string(err, test)

        if err is not None:
            if issubclass(err[0], ElbeTestException):
                self.current_case.stdout = err[1].out

        self.current_case.add_error_info(message, output)
        super().addError(test, err)

    def addFailure(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
           returned by sys.exc_info()."""

        message = str(err[1])

# Path: elbepack/shellhelper.py
# def command_out(cmd, stdin=None, output=PIPE, env_add=None):
#     """command_out() - Execute cmd in a shell.
# 
#     Returns a tuple with the exitcode and the output of cmd.
# 
#     --
# 
#     >>> command_out("true")
#     (0, '')
# 
#     >>> command_out("$TRUE && true", env_add={"TRUE":"true"})
#     (0, '')
# 
#     >>> command_out("cat -", stdin=b"ELBE")
#     (0, 'ELBE')
# 
#     >>> command_out("2>&1 cat -", stdin=b"ELBE")
#     (0, 'ELBE')
# 
#     >>> command_out("2>&1 cat -", stdin="ELBE")
#     (0, 'ELBE')
# 
#     >>> command_out("false")
#     (1, '')
# 
#     """
#     new_env = os.environ.copy()
#     if env_add:
#         new_env.update(env_add)
# 
#     if isinstance(stdin, str):
#         stdin = stdin.encode()
# 
#     if stdin is None:
#         p = Popen(cmd, shell=True,
#                   stdout=output, stderr=STDOUT, env=new_env)
#         out, _ = p.communicate()
#     else:
#         p = Popen(cmd, shell=True,
#                   stdout=output, stderr=STDOUT, stdin=PIPE, env=new_env)
#         out, _ = p.communicate(input=stdin)
# 
#     out = TextIOWrapper(BytesIO(out), encoding='utf-8', errors='replace').read()
# 
#     return p.returncode, out


# Path: elbepack/commands/test.py
import enum
import optparse
import os
import re
import unittest
import warnings
import junit_xml as junit
from elbepack.shellhelper import command_out

    def __init__(self):
        super().__init__()
        self.cases = []
        self.current_case = None

    def startTest(self, test):
        self.current_case = junit.TestCase(name=str(test))
        self.cases.append(self.current_case)
        super().startTest(test)

    def addError(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
           returned by sys.exc_info().
        """

        message = str(err[1])
        output = self._exc_info_to_string(err, test)

        if err is not None:
            if issubclass(err[0], ElbeTestException):
                self.current_case.stdout = err[1].out

        self.current_case.add_error_info(message, output)
        super().addError(test, err)

    def addFailure(self, test, err):
        """Called when an error has occurred. 'err' is a tuple of values as
           returned by sys.exc_info()."""

        message = str(err[1])

        output = self._exc_info_to_string(err, test)