3 ms·
This is really cool, and would be especially useful for unit testing like the article says!
by hiyer 5y ago
This is really cool, and would be especially useful for unit testing like the article says!
- michael-ax 5y agoput your tests into the module! . . # exit when sourcing [ "$0" == "${BASH_SOURCE[0]}" ] || return 0 echo "Tests for [$0]" . . this way you'll wind up able to load/source globs of reusable self testing code into the global namespace with ease. add a [ -n "$1" ] && { undef and exit } block at the top of the file where you document the names you're using as you would in a header.c and packaging your code for reuse becomes easy. at last count i have 19 such modules in /ops/bash. they are immensely useful to help me remember this atrocious language :)
- sigzero 5y agoI am having a hard time conceptualizing that (maybe I need caffeine). Could you post an example?