Skip to content

Commit 395fe06

Browse files
vitalystermoiseev
authored andcommitted
swift_build_support: do not raise exception when capturing shell with… (#5380)
* swift_build_support: do not raise exception when capturing shell with optional flag This fixes one of https://bugs.swift.org/browse/SR-2966 failed tests when testing environment trying to instantiate FreeBSD toolchain on Linux and `sysctl` is not in the PATH * swift_build_support: fix shell test
1 parent 01e7829 commit 395fe06

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

utils/swift_build_support/swift_build_support/shell.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def capture(command, stderr=None, env=None, dry_run=None, echo=True,
123123
"command terminated with a non-zero exit status " +
124124
str(e.returncode) + ", aborting")
125125
except OSError as e:
126+
if optional:
127+
return None
126128
diagnostics.fatal(
127129
"could not execute '" + quote_command(command) +
128130
"': " + e.strerror)

utils/swift_build_support/tests/test_shell.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def test_capture(self):
7676
allow_non_zero_exit=True), "foo\n")
7777

7878
with self.assertRaises(SystemExit):
79-
shell.capture(["**not-a-command**"], optional=True)
79+
shell.capture(["**not-a-command**"], optional=False)
80+
81+
self.assertIsNone(shell.capture(["**not-a-command**"], optional=True))
8082

8183
def test_rmtree(self):
8284
shell.dry_run = False

0 commit comments

Comments
 (0)