Skip to content

Commit

Permalink
v0.2.35: more terse output, hiding traceback from build.executables.run
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Jun 9, 2016
1 parent c212c3f commit d8002d1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
]

setup(name='uranium',
version='0.2.34b',
version='0.2.35b',
description='a build system for python',
long_description=open('README.rst').read(),
author='Yusuke Tsutsumi',
Expand Down
12 changes: 12 additions & 0 deletions tests/test_executables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
from uranium.exceptions import NonZeroExitCodeException


def test_hello_world(capfd, executables):
desired_output = "hello, world"
executables.run(["echo", "{0}".format(desired_output)],
subprocess_args={"stdin": None})
out, err = capfd.readouterr()
assert out.strip() == "hello, world"


def test_exception_contains_executable_name(capfd, executables):
try:
executables.run(["grep"])
except NonZeroExitCodeException as e:
assert "grep" in str(e)
else:
assert False
21 changes: 20 additions & 1 deletion tests/test_executables_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .conftest import URANIUM_SOURCE_ROOT


def test_pytest_avaliable_after_install(tmpdir):
def test_pytest_available_after_install(tmpdir):
""" pytest should be available after an installation. """

UBUILD = """
Expand All @@ -19,3 +19,22 @@ def main(build):
print("stdout:\n" + str(out))
print("stderr:\n" + str(err))
assert "2.7.0" in out.decode("utf-8")


def test_no_traceback_on_bad_error_code(tmpdir):
""" pytest should be available after an installation. """

UBUILD = """
def main(build):
# grep with no arguments is a non-zero exit code.
build.executables.run(["grep"])
""".strip()

tmpdir.join("ubuild.py").write(UBUILD)
code, out, err = execute_script(
"uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath
)
print("stdout:\n" + str(out))
print("stderr:\n" + str(err))
assert "Traceback" not in out.decode("utf-8")
14 changes: 7 additions & 7 deletions uranium/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ class HooksException(UraniumException):
pass


class NonZeroExitCodeException(UraniumException):
class PluginException(UraniumException):
""" an exception that occurred with the plugin """
pass


class PackageException(UraniumException):
""" exceptions with the package object """
class ScriptException(UraniumException):
pass


class PluginException(UraniumException):
""" an exception that occurred with the plugin """
class ConfigException(ScriptException):
pass


class ScriptException(UraniumException):
class NonZeroExitCodeException(ScriptException):
pass


class ConfigException(UraniumException):
class PackageException(UraniumException):
""" exceptions with the package object """
pass
6 changes: 5 additions & 1 deletion uranium/executables.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ def main(build):
exit_code = popen.returncode

if exit_code != 0 and fail_on_error:
raise NonZeroExitCodeException("received non-zero exit code: {0}".format(exit_code))
raise NonZeroExitCodeException(
"{0} returned non-zero exit code: {1}".format(
args[0], exit_code
)
)
return exit_code, out, err

def install_script(self, name, body, execution_dir="base"):
Expand Down
8 changes: 2 additions & 6 deletions uranium/lib/log_templates.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
STARTING_URANIUM = """
================
STARTING URANIUM
================
=== START URANIUM ===
""".strip()

ENDING_URANIUM = """
================
URANIUM FINISHED
================
=== URANIUM FINISHED ===
""".strip()

0 comments on commit d8002d1

Please sign in to comment.