| #!/bin/bash | |
| set -eu | |
| THIS="$(readlink -f "$0")" | |
| THISDIR="$(dirname "${THIS}")" | |
| SRCDIR="$(dirname "${THISDIR}")" | |
| ################################################################################ | |
| # Take makeself options, generate a predefined archive, print --lsm to stdout. | |
| # | |
| # $@ : makeself options | |
| withlsm() ( | |
| cd "${SRCDIR}" | |
| mkdir -p lsmtest | |
| ./makeself.sh "$@" ./lsmtest ./lsmtest.run lsmtest ls -lah >/dev/null 2>&1 | |
| assertEquals "$?" 0 >&2 | |
| ./lsmtest.run --lsm | |
| assertEquals "$?" 0 >&2 | |
| rm -rf lsmtest lsmtest.run | |
| ) | |
| test_lsm_empty() { | |
| printf '' >lsm_empty.txt | |
| wc lsm_empty.txt | |
| withlsm --lsm lsm_empty.txt | |
| rm -f lsm_empty.txt | |
| } | |
| test_lsm_one_line() { | |
| printf 'one line\n' >lsm_one_line.txt | |
| withlsm --lsm lsm_one_line.txt | |
| rm -f lsm_one_line.txt | |
| } | |
| test_lsm_one_line_without_nl() { | |
| printf 'one line without nl' >lsm_one_line_without_nl.txt | |
| withlsm --lsm lsm_one_line_without_nl.txt | |
| rm -f lsm_one_line_without_nl.txt | |
| } | |
| ################################################################################ | |
| # Load and run shUnit2. | |
| source "./shunit2/shunit2" |