cartesi / machine-emulator

The off-chain implementation of the Cartesi Machine
GNU Lesser General Public License v3.0
64 stars 33 forks source link

Use `set -e` and `trap` to improve test shell-script #182

Open mpolitzer opened 8 months ago

mpolitzer commented 8 months ago

Context

What problem are you trying to solve?

Code improvement

As per: https://github.com/cartesi/machine-emulator/pull/171#pullrequestreview-1853671076

We could automate cleanup and exit on any error for scripts: tests/scripts/test-jsonrpc-server.sh and tests/scripts/test-grpc-server.sh.

with:

set -e
trap wait_for_shutdown EXIT

note: here docs return false for whatever reason, use this trick to make them work.

cat << EOF | true
EOF