| Q | A |
|---|
| OS | Linux (Cygwin on Windows) |
| Shell & version | bash 5.2.21(1)-release |
| bashunit version | 0.33.0 |
Summary
Spying on or mocking echo or printf causes unit tests to hang
Current behavior

Didn't look until I tried using printf instead of echo but it looks like it's causing bashunit to infinitely spawn processes somewhere.
How to reproduce
functionwrite_data_to_coproc() {
if [ -z"$COPROC" ];thenreturn 1
fiecho>&"${COPROC[0]}""set_data: $*"
}
functiontest_write_data_to_coproc() {
COPROC=(12 13)
bashunit::spy echo
write_data_to_coproc "hello world"
assert_have_been_called_with echo"set_data: hello world"
}Probable cause
Unprotected calls to echo/printf instead of using builtin echo/builtin printf
Expected behavior
Unit test completes and bashunit doesn't hang forever.
Summary
Spying on or mocking
echoorprintfcauses unit tests to hangCurrent behavior
Didn't look until I tried using printf instead of echo but it looks like it's causing bashunit to infinitely spawn processes somewhere.
How to reproduce
Probable cause
Unprotected calls to
echo/printfinstead of usingbuiltin echo/builtin printfExpected behavior
Unit test completes and bashunit doesn't hang forever.