Command.run() currently has a bit of a confusing behavior: if raise_on_error is
False and the executable is not found, then a weird CommandT is returned (return
code is -1 and stdout+stderr is None). This makes it possible to hanlde command
not found errors separately, but it makes that needlessly verbose. So instead,
let's just return None in *this* special case.
That in turn uncovered, that in most cases when we set `raise_on_error=True`, we
actually want an error if the command is not present but no error if the command
fails to execute (e.g. because it returns -1 if you run `$cmd --version`). Hence we
introduce the flag `raise_on_command_not_found`, which causes an exception to
be raised if the command is not found. This makes it independent of the
`raise_on_error` flag.
Additionally, we add a small optimization: if command starts with /, then we
assume it's a full path and we omit the call to which (and just check whether it
exists).
Co-authored-by: Marcus Schäfer <marcus.schaefer@gmail.com>
This commit prevents the use of a default stdout and stderr in case
return code reports errors and it is not raising an exception.
If we are not raising an exception there is no specific need to
artificially append some stdout and stderr default message, we just
behave as if there was no error.
On validation error we use jing to report detailed error
messages. However if jing is not present no validation
errors are displayed. There is a error_log variable as
part of the relaxNG object which holds the library error
log. This information is not as good as the jing report
but better than nothing
Use raises as context manager instead of a method decorator.
This clearly identifies which code part is expected to raise
an exception. Related to Issue #1128
Command.run and Command.call now make use of Path.which in order
to test if the command is available or not. Also Path.which has
been extended in order to support custom environments and to be
able to test file permissions (read. write, execute)
This commit includes a validation in Command.run and Command.call
in order to verify the existance of the command before running it.
It case it is not found in the specified environment it raises a
KiwiCommandNotFound Exception.
nose is no longer maintained, thus we have to move to another
testing system. This commit updates the tox setup and all tests
to use pytest instead of nose.