I have a python makefile. I can run its commands from my bash script as below
local make_lint_output=""
make_lint_output="$( make test-unit 2>&1 )"
echo "${make_lint_output}"
local result=$?
if (( result == 0 )); then
return 1
fi
But the problem is it always return $? as 0 even though make command exits with an error.
On failure part of the output is like below
E ImportError: No module named 'serial' !!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!! =========================== 3 error in 0.17 seconds ============================ Makefile:61: recipe for target 'test-power-control' failed
$? should be return other than 0 in this case. What am I missing here? I m running the bash script in unix machine.
! make test-unit 2>&1. The output will then be written to stdout rather than captured by the shell before being written to stdout via echo, and the return value will be appropriately inverted as your if statement is doing.