Closed p-podsiadly closed 4 years ago
Thank very much for this.
I will try this out tomorrow. I need to think through the cases. As far as I recall, in each of these cases, at the time we deliberately ignored the result of the system call - so I would like to think it through, to think whether the exception would be a problem.
On reflection, I definitely agree that the ClipboardReporter case is worth throwing.
There are lots of other calls to system that remain, and which definitely should not throw. So I think it would be better for runSystemCommand() to have a more specific name, to avoid the temptation for someone to use it in more places in future.
Perhaps runSystemCommandOrThrow()?
Hello @p-podsiadly,
I will try this out tomorrow. I need to think through the cases. As far as I recall, in each of these cases, at the time we deliberately ignored the result of the system call - so I would like to think it through, to think whether the exception would be a problem.
I've just reviewed them, and they are all clearly worth checking, so I've accepted the PR.
There are lots of other calls to system that remain, and which definitely should not throw. So I think it would be better for runSystemCommand() to have a more specific name, to avoid the temptation for someone to use it in more places in future.
Perhaps runSystemCommandOrThrow()?
Don't worry about this - I'll do it...
Many thanks for this - it's a definite improvement!
Description
When building another project including ApprovalTests as a git submodule, I've got the following warnings:
caused by calls to
system()
(inClipboardReporter.h
,FileUtilsSystemSpecific.h
andSystemLauncher.h
).The solution
This commit replaces unchecked calls to
system()
with calls to a new methodSystemUtils::runSystemCommand()
, which throwsstd::runtime_error
if the exit code is not 0.Apart from suppressing the warning, this should help to locate a problem, if any of those commands actually fail.