| #!/bin/bash | |
| set -eu | |
| THIS="$(readlink -f "$0")" | |
| THISDIR="$(dirname "${THIS}")" | |
| SUT="$(dirname "${THISDIR}")/makeself.sh" | |
| setupTests() { | |
| temp=`mktemp -d -t XXXXX` | |
| cd "$temp" | |
| mkdir archive | |
| touch archive/file | |
| archive_name=${2:-"makeself-test.run"} | |
| # $SUT archive makeself-test.run "Test $1" declare -p "${1}" | |
| $SUT archive "${archive_name}" "Test $1" echo \\\"\${${1}}\\\" | |
| } | |
| testArchiveDir() | |
| { | |
| setupTests ARCHIVE_DIR | |
| local ans=$'./complicated\n dir\twith spaces' | |
| mkdir "${ans}" | |
| mv ./makeself-test.run "${ans}/" | |
| actual_archive_dir="$("${ans}/makeself-test.run" --quiet)" | |
| assertEquals "${actual_archive_dir}" "${ans}" | |
| } | |
| testTmpRoot() | |
| { | |
| setupTests TMPROOT | |
| local ans="${temp}"$'/complicated\n dir\twith spaces' | |
| mkdir -p "${ans}" | |
| actual_tmp_root="$(TMPDIR="${ans}" "./makeself-test.run" --quiet)" | |
| assertEquals "${actual_tmp_root}" "${ans}" | |
| } | |
| testUserPWD() | |
| { | |
| setupTests USER_PWD | |
| local ans="${temp}"$'/complicated\n dir\twith spaces' | |
| mkdir -p "${ans}" | |
| cd "${ans}" | |
| actual_user_pwd="$("${temp}/makeself-test.run" --quiet)" | |
| assertEquals "${actual_user_pwd}" "${ans}" | |
| } | |
| testArchiveName() | |
| { | |
| local ans="`mktemp -u XXXXXX`.run" | |
| setupTests ARCHIVE_NAME "${ans}" | |
| actual_archive_name="$("${temp}/${ans}" --quiet)" | |
| assertEquals "${actual_archive_name}" "${ans}" | |
| } | |
| # Load and run shUnit2. | |
| source "./shunit2/shunit2" |