Skip to content

[utils] Improve swift_build_support.shell failure messages. #2831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion utils/swift_build_support/swift_build_support/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import sys
from contextlib import contextmanager

from . import diagnostics

dry_run = False


Expand Down Expand Up @@ -66,7 +68,16 @@ def call(command, stderr=None, env=None, dry_run=None):
if env is not None:
_env = dict(os.environ)
_env.update(env)
subprocess.check_call(command, env=_env, stderr=stderr)
try:
subprocess.check_call(command, env=_env, stderr=stderr)
except subprocess.CalledProcessError as e:
diagnostics.fatal(
"command terminated with a non-zero exit status " +
str(e.returncode) + ", aborting")
except OSError as e:
diagnostics.fatal(
"could not execute '" + quote_command(command) +
"': " + e.strerror)


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion utils/swift_build_support/tests/test_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_tar_this_file_succeeds(self):
expect.format(dest=destination, source=source))

def test_tar_nonexistent_file_raises(self):
with self.assertRaises(subprocess.CalledProcessError):
with self.assertRaises(SystemExit):
tar(source='/path/to/something/that/surely/doesnt/exist',
destination='/another/path/that/shouldnt/exist')

Expand Down