-
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e94247
commit c0c258f
Showing
4 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/bash | ||
set -eu | ||
THIS="$(readlink -f "$0")" | ||
THISDIR="$(dirname "${THIS}")" | ||
SUT="$(dirname "${THISDIR}")/makeself.sh" | ||
|
||
setUp() { | ||
temp=$(mktemp -d -t XXXXX) | ||
pushd "${temp}" | ||
mkdir src | ||
echo "echo This is a test" > src/startup.sh | ||
chmod a+x src/startup.sh | ||
} | ||
|
||
tearDown() { | ||
popd | ||
rm -rf "${temp}" | ||
} | ||
|
||
testPreextractOpts() { | ||
echo 'echo A complex pre-extraction script. | ||
sleep 99 & | ||
cat a.txt 2>/dev/null || cat b.txt && cat c.txt | ||
echo "$$ Some\toutput\n\a\b\0777 $var1 ${var2} `cat var3.txt` $(env)" > text.txt | ||
' > preextract.sh | ||
|
||
${SUT} --nox11 --preextract preextract.sh src src.sh alabel ./startup.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh --show-preextract > show-preextract.out | ||
assertEquals 0 $? | ||
|
||
diff preextract.sh show-preextract.out | ||
assertEquals 0 $? | ||
} | ||
|
||
testWithNoPreextractOpts() { | ||
${SUT} src src.sh alabel ./startup.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh --show-preextract | ||
assertEquals 1 $? | ||
} | ||
|
||
testPreextractRun() { | ||
echo 'echo Validating provided options...' > preextract.sh | ||
${SUT} --nox11 --preextract preextract.sh src src.sh alabel ./startup.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh | grep -qF 'Validating provided options...' | ||
assertEquals 0 $? | ||
} | ||
|
||
testPreextractNoexec() { | ||
echo 'exit 2' > preextract.sh | ||
${SUT} --preextract preextract.sh src src.sh alabel ./startup.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh | ||
assertEquals 1 $? | ||
|
||
./src.sh --noexec | ||
assertEquals 0 $? | ||
} | ||
|
||
testPreextractArgs() { | ||
echo 'echo $*' > preextract.sh | ||
${SUT} --nox11 --preextract preextract.sh src src.sh alabel ./startup.sh --logdir /var/log | ||
assertEquals 0 $? | ||
|
||
test_cmd='./src.sh -- --env dev' | ||
|
||
eval "${test_cmd}" | ||
assertEquals 0 $? | ||
|
||
eval "${test_cmd}" | grep -qF -- '--logdir /var/log --env dev' | ||
assertEquals 0 $? | ||
} | ||
|
||
testPreextractEnvPassing() { | ||
# imitate user input | ||
echo 'echo "export INSTALLATION_DIR=/usr/bin" > preextract.env' > preextract.sh | ||
echo '. ./preextract.env; echo $INSTALLATION_DIR' > src/startup.sh | ||
${SUT} --nox11 --preextract preextract.sh src src.sh alabel ./startup.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh | ||
assertEquals 0 $? | ||
|
||
./src.sh | grep -qF '/usr/bin' | ||
assertEquals 0 $? | ||
} | ||
|
||
# Load and run shUnit2. | ||
source "./shunit2/shunit2" |