Added plugins and build tools
This commit is contained in:
26
tools/makeself-2.4.5/test/bashunit/LICENSE
Normal file
26
tools/makeself-2.4.5/test/bashunit/LICENSE
Normal file
@ -0,0 +1,26 @@
|
||||
Copyright (c) 2012, Uwe Dauernheim <uwe@dauernheim.net>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
150
tools/makeself-2.4.5/test/bashunit/README.md
Normal file
150
tools/makeself-2.4.5/test/bashunit/README.md
Normal file
@ -0,0 +1,150 @@
|
||||
# bashunit
|
||||
|
||||
`bashunit` is a unit testing framework for Bash scripts based on xUnit principles.
|
||||
|
||||
This is similar to the [ShUnit](http://shunit.sourceforge.net/) and its
|
||||
successor [shUnit2](https://code.google.com/p/shunit2/).
|
||||
|
||||
## Usage
|
||||
|
||||
Functions starting with 'test' will be automatically evaluated.
|
||||
|
||||
**1. Write test cases**
|
||||
|
||||
```bash
|
||||
testEcho() {
|
||||
assertEqual "$(echo foo)" "foo"
|
||||
assertReturn "$(echo foo)" 0
|
||||
}
|
||||
```
|
||||
|
||||
**2. Include this script at the end of your test script**
|
||||
|
||||
```bash
|
||||
source $(dirname $0)/bashunit.bash
|
||||
|
||||
# eof
|
||||
```
|
||||
|
||||
**3. Run test suite**
|
||||
|
||||
```bash
|
||||
$ ./test_example
|
||||
testEcho:4:Passed
|
||||
testEcho:5:Passed
|
||||
Done. 2 passed. 0 failed. 0 skipped.
|
||||
```
|
||||
|
||||
The return code is equal to the amount of failed testcases.
|
||||
|
||||
Options can be given to the test script:
|
||||
|
||||
```bash
|
||||
$ bash ./bashunit.bash
|
||||
Usage: <testscript> [options...]
|
||||
|
||||
Options:
|
||||
-v, --verbose Print exptected and provided values
|
||||
-s, --summary Only print summary omitting individual test results
|
||||
-q, --quiet Do not print anything to standard output
|
||||
-h, --help Show usage screen
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
* Bash (`BASH_LINENO`)
|
||||
* Shell colours
|
||||
|
||||
## API
|
||||
|
||||
* `assert($1)`
|
||||
|
||||
`$1`: Expression
|
||||
|
||||
Assert that a given expression evaluates to true.
|
||||
|
||||
* `assertEqual($1, $2)`
|
||||
|
||||
`$1`: Output
|
||||
|
||||
`$2`: Expected
|
||||
|
||||
Assert that a given output string is equal to an expected string.
|
||||
|
||||
* `assertNotEqual($1, $2)`
|
||||
|
||||
`$1`: Output
|
||||
|
||||
`$2`: Expected
|
||||
|
||||
Assert that a given output string is not equal to an expected string.
|
||||
|
||||
* `assertStartsWith($1, $2)`
|
||||
|
||||
`$1`: Output
|
||||
|
||||
`$2`: Expected
|
||||
|
||||
Assert that a given output string starts with an expected string.
|
||||
|
||||
* `assertReturn($1, $2)`
|
||||
|
||||
`$1`: Output
|
||||
|
||||
`$2`: Expected
|
||||
|
||||
`$?`: Provided
|
||||
|
||||
Assert that the last command's return code is equal to an expected integer.
|
||||
|
||||
* `assertNotReturn($1, $2)`
|
||||
|
||||
`$1`: Output
|
||||
|
||||
`$2`: Expected
|
||||
|
||||
`$?`: Provided
|
||||
|
||||
Assert that the last command's return code is not equal to an expected
|
||||
integer.
|
||||
|
||||
* `assertGreaterThan($1, $2)`
|
||||
|
||||
`$1` Output
|
||||
|
||||
`$2` Expected
|
||||
|
||||
Assert that a given integer is greater than an expected integer.
|
||||
|
||||
* `assertAtLeast($1, $2)`
|
||||
|
||||
`$1` Output
|
||||
|
||||
`$2` Expected
|
||||
|
||||
Assert that a given integer is greater than or equal to an expected integer.
|
||||
|
||||
* `assertLessThan($1, $2)`
|
||||
|
||||
`$1` Output
|
||||
|
||||
`$2` Expected
|
||||
|
||||
Assert that a given integer is less than an expected integer.
|
||||
|
||||
* `assertAtMost($1, $2)`
|
||||
|
||||
`$1` Output
|
||||
|
||||
`$2` Expected
|
||||
|
||||
Assert that a given integer is less than or equal to an expected integer.
|
||||
|
||||
* `skip()`
|
||||
|
||||
Skip the current test case.
|
||||
|
||||
## License
|
||||
|
||||
`bashunit` is licenced under a
|
||||
[BSD License](https://github.com/djui/bashunit/blob/master/LICENSE).
|
189
tools/makeself-2.4.5/test/bashunit/bashunit.bash
Normal file
189
tools/makeself-2.4.5/test/bashunit/bashunit.bash
Normal file
@ -0,0 +1,189 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
########################################################################
|
||||
# GLOBALS
|
||||
########################################################################
|
||||
|
||||
verbose=2
|
||||
|
||||
bashunit_passed=0
|
||||
bashunit_failed=0
|
||||
bashunit_skipped=0
|
||||
|
||||
########################################################################
|
||||
# ASSERT FUNCTIONS
|
||||
########################################################################
|
||||
|
||||
# Assert that a given expression evaluates to true.
|
||||
#
|
||||
# $1: Expression
|
||||
assert() {
|
||||
if test $* ; then _passed ; else _failed "$*" true ; fi
|
||||
}
|
||||
|
||||
# Assert that a given output string is equal to an expected string.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertEqual() {
|
||||
echo $1 | grep -E "^$2$" > /dev/null
|
||||
if [ $? -eq 0 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that a given output string is not equal to an expected string.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertNotEqual() {
|
||||
echo $1 | grep -E "^$2$" > /dev/null
|
||||
if [ $? -ne 0 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that a given output string starts with an expected string.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertStartsWith() {
|
||||
echo $1 | grep -E "^$2" > /dev/null
|
||||
if [ $? -eq 0 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that the last command's return code is equal to an expected integer.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
# $?: Provided
|
||||
assertReturn() {
|
||||
local code=$?
|
||||
if [ $code -eq $2 ] ; then _passed ; else _failed "$code" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that the last command's return code is not equal to an expected integer.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
# $?: Provided
|
||||
assertNotReturn() {
|
||||
local code=$?
|
||||
if [ $code -ne $2 ] ; then _passed ; else _failed "$code" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that a given integer is greater than an expected integer.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertGreaterThan() {
|
||||
if [ $1 -gt $2 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that a given integer is greater than or equal to an expected integer.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertAtLeast() {
|
||||
if [ $1 -ge $2 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that a given integer is less than an expected integer.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertLessThan() {
|
||||
if [ $1 -lt $2 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Assert that a given integer is less than or equal to an expected integer.
|
||||
#
|
||||
# $1: Output
|
||||
# $2: Expected
|
||||
assertAtMost() {
|
||||
if [ $1 -le $2 ] ; then _passed ; else _failed "$1" "$2" ; fi
|
||||
}
|
||||
|
||||
# Skip the current test case.
|
||||
#
|
||||
skip() {
|
||||
_skipped
|
||||
}
|
||||
|
||||
_failed() {
|
||||
bashunit_failed=$((bashunit_failed+1))
|
||||
|
||||
local tc=${FUNCNAME[2]}
|
||||
local line=${BASH_LINENO[1]}
|
||||
if [ $verbose -ge 2 ] ; then
|
||||
echo -e "\033[37;1m$tc\033[0m:$line:\033[31mFailed\033[0m"
|
||||
fi
|
||||
if [ $verbose -eq 3 ] ; then
|
||||
echo -e "\033[31mExpected\033[0m: $2"
|
||||
echo -e "\033[31mProvided\033[0m: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
_passed() {
|
||||
bashunit_passed=$((bashunit_passed+1))
|
||||
|
||||
local tc=${FUNCNAME[2]}
|
||||
local line=${BASH_LINENO[1]}
|
||||
if [ $verbose -ge 2 ] ; then
|
||||
echo -e "\033[37;1m$tc\033[0m:$line:\033[32mPassed\033[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
_skipped() {
|
||||
bashunit_skipped=$((bashunit_skipped+1))
|
||||
|
||||
local tc=${FUNCNAME[2]}
|
||||
local line=${BASH_LINENO[1]}
|
||||
if [ $verbose -ge 2 ] ; then
|
||||
echo -e "\033[37;1m$tc\033[0m:$line:\033[33mSkipped\033[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
########################################################################
|
||||
# RUN
|
||||
########################################################################
|
||||
|
||||
usage() {
|
||||
echo "Usage: <testscript> [options...]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -v, --verbose Print exptected and provided values"
|
||||
echo " -s, --summary Only print summary omitting individual test results"
|
||||
echo " -q, --quiet Do not print anything to standard output"
|
||||
echo " -h, --help Show usage screen"
|
||||
}
|
||||
|
||||
runTests() {
|
||||
local test_pattern="test[a-zA-Z0-9_]\+"
|
||||
local testcases=$(grep "^ *\(function \)*$test_pattern *\\(\\)" $0 | \
|
||||
grep -o $test_pattern)
|
||||
|
||||
if [ ! "${testcases[*]}" ] ; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for tc in $testcases ; do $tc ; done
|
||||
|
||||
if [ $verbose -ge 1 ] ; then
|
||||
echo "Done. $bashunit_passed passed." \
|
||||
"$bashunit_failed failed." \
|
||||
"$bashunit_skipped skipped."
|
||||
fi
|
||||
exit $bashunit_failed
|
||||
}
|
||||
|
||||
# Arguments
|
||||
while [ $# -gt 0 ]; do
|
||||
arg=$1; shift
|
||||
case $arg in
|
||||
"-v"|"--verbose") verbose=3;;
|
||||
"-s"|"--summary") verbose=1;;
|
||||
"-q"|"--quiet") verbose=0;;
|
||||
"-h"|"--help") usage; exit 0;;
|
||||
*) shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
runTests
|
19
tools/makeself-2.4.5/test/bashunit/test_example
Executable file
19
tools/makeself-2.4.5/test/bashunit/test_example
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
testEcho() {
|
||||
assertEqual "$(echo foo)" "foo"
|
||||
assertReturn "$(echo foo)" 0
|
||||
}
|
||||
|
||||
testTest() {
|
||||
assert "-e $0"
|
||||
}
|
||||
|
||||
testArithmetic() {
|
||||
assertGreaterThan "$(( 1 + 1 ))" "1"
|
||||
assertAtLeast "$(( 1 + 1 ))" "2"
|
||||
assertLessThan "$(( 1 + 1 ))" "5"
|
||||
assertAtMost "$(( 1 + 1 ))" "2"
|
||||
}
|
||||
|
||||
source $(dirname $0)/bashunit.bash
|
Reference in New Issue
Block a user