mirror of
https://github.com/fsquillace/junest.git
synced 2026-01-23 02:34:30 +00:00
Add unit tests
This commit is contained in:
parent
65c45517e1
commit
a9174267b3
4 changed files with 17 additions and 17 deletions
|
|
@ -41,22 +41,22 @@ function init_mocks() {
|
|||
|
||||
function test_run_env_as_groot_cmd(){
|
||||
assertCommandSuccess run_env_as_groot "" "" "false" pwd
|
||||
assertEquals "chroot_cmd -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login -c pwd" "$(cat "$STDOUTF")"
|
||||
assertEquals "chroot_cmd -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login -c pwd" "$(cat "$STDOUTF")"
|
||||
}
|
||||
|
||||
function test_run_env_as_groot_no_cmd(){
|
||||
assertCommandSuccess run_env_as_groot "" "" "false" ""
|
||||
assertEquals "chroot_cmd -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login" "$(cat "$STDOUTF")"
|
||||
assertEquals "chroot_cmd -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login" "$(cat "$STDOUTF")"
|
||||
}
|
||||
|
||||
function test_run_env_as_groot_with_backend_command(){
|
||||
assertCommandSuccess run_env_as_groot "mychroot" "" "false" ""
|
||||
assertEquals "mychroot -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login" "$(cat "$STDOUTF")"
|
||||
assertEquals "mychroot -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login" "$(cat "$STDOUTF")"
|
||||
}
|
||||
|
||||
function test_run_env_as_groot_no_copy(){
|
||||
assertCommandSuccess run_env_as_groot "" "" "true" pwd
|
||||
assertEquals "chroot_cmd -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login -c pwd" "$(cat "$STDOUTF")"
|
||||
assertEquals "chroot_cmd -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev $JUNEST_HOME /bin/sh --login -c pwd" "$(cat "$STDOUTF")"
|
||||
|
||||
[[ ! -e ${JUNEST_HOME}/etc/hosts ]]
|
||||
assertEquals 0 $?
|
||||
|
|
@ -76,7 +76,7 @@ function test_run_env_as_groot_nested_env(){
|
|||
|
||||
function test_run_env_as_groot_cmd_with_backend_args(){
|
||||
assertCommandSuccess run_env_as_groot "" "-n -b /home/blah" "false" pwd
|
||||
assertEquals "chroot_cmd -b $HOME -b /tmp -b /proc -b /sys -b /dev -n -b /home/blah $JUNEST_HOME /bin/sh --login -c pwd" "$(cat "$STDOUTF")"
|
||||
assertEquals "chroot_cmd -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev -n -b /home/blah $JUNEST_HOME /bin/sh --login -c pwd" "$(cat "$STDOUTF")"
|
||||
}
|
||||
|
||||
function test_run_env_as_chroot_cmd(){
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ function test_run_env_as_proot_user(){
|
|||
echo $*
|
||||
}
|
||||
assertCommandSuccess run_env_as_proot_user "" "-k 3.10" "false" "/usr/bin/mkdir" "-v" "/newdir2"
|
||||
assertEquals "-b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
assertEquals "-b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
|
||||
SH=("/usr/bin/echo")
|
||||
assertCommandSuccess run_env_as_proot_user "" "-k 3.10" "false"
|
||||
assertEquals "-b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
assertEquals "-b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
|
||||
_test_copy_common_files
|
||||
_test_copy_remaining_files
|
||||
|
|
@ -72,11 +72,11 @@ function test_run_env_as_proot_user_with_backend_command(){
|
|||
echo $*
|
||||
}
|
||||
assertCommandSuccess run_env_as_proot_user "myproot" "-k 3.10" "false" "/usr/bin/mkdir" "-v" "/newdir2"
|
||||
assertEquals "myproot -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
assertEquals "myproot -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
|
||||
SH=("/usr/bin/echo")
|
||||
assertCommandSuccess run_env_as_proot_user "myproot" "-k 3.10" "false"
|
||||
assertEquals "myproot -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
assertEquals "myproot -b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
|
||||
_test_copy_common_files
|
||||
_test_copy_remaining_files
|
||||
|
|
@ -89,7 +89,7 @@ function test_run_env_as_proot_user_no_copy(){
|
|||
echo $*
|
||||
}
|
||||
assertCommandSuccess run_env_as_proot_user "" "-k 3.10" "true" "/usr/bin/mkdir" "-v" "/newdir2"
|
||||
assertEquals "-b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
assertEquals "-b /run/user/$(id -u) -b $HOME -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
|
||||
[[ ! -e ${JUNEST_HOME}/etc/hosts ]]
|
||||
assertEquals 0 $?
|
||||
|
|
@ -126,11 +126,11 @@ function test_run_env_as_proot_fakeroot(){
|
|||
echo $*
|
||||
}
|
||||
assertCommandSuccess run_env_as_proot_fakeroot "" "-k 3.10" "false" "/usr/bin/mkdir" "-v" "/newdir2"
|
||||
assertEquals "-0 -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
assertEquals "-0 -b /run/user/$(id -u) -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
|
||||
SH=("/usr/bin/echo")
|
||||
assertCommandSuccess run_env_as_proot_fakeroot "" "-k 3.10" "false"
|
||||
assertEquals "-0 -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
assertEquals "-0 -b /run/user/$(id -u) -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
|
||||
_test_copy_common_files
|
||||
}
|
||||
|
|
@ -142,12 +142,12 @@ function test_run_env_as_proot_fakeroot_with_backend_command(){
|
|||
echo $*
|
||||
}
|
||||
assertCommandSuccess run_env_as_proot_fakeroot "myproot" "-k 3.10" "false" "/usr/bin/mkdir" "-v" "/newdir2"
|
||||
assertEquals "myproot -0 -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
assertEquals "myproot -0 -b /run/user/$(id -u) -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
|
||||
# shellcheck disable=SC2034
|
||||
SH=("/usr/bin/echo")
|
||||
assertCommandSuccess run_env_as_proot_fakeroot "myproot" "-k 3.10" "false"
|
||||
assertEquals "myproot -0 -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
assertEquals "myproot -0 -b /run/user/$(id -u) -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10" "$(cat "$STDOUTF")"
|
||||
|
||||
_test_copy_common_files
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ function test_run_env_with_quotes(){
|
|||
echo $*
|
||||
}
|
||||
assertCommandSuccess run_env_as_proot_user "" "-k 3.10" "false" "bash" "-c" "/usr/bin/mkdir -v /newdir2"
|
||||
assertEquals "-b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 bash -c /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
assertEquals "-b /run/user/$(id -u) -b ${HOME} -b /tmp -b /proc -b /sys -b /dev -r ${JUNEST_HOME} -k 3.10 bash -c /usr/bin/mkdir -v /newdir2" "$(cat "$STDOUTF")"
|
||||
}
|
||||
|
||||
function test_run_env_with_proot_args(){
|
||||
|
|
|
|||
|
|
@ -987,7 +987,7 @@ _shunit_extractTestFunctions()
|
|||
# extract the lines with test function names, strip of anything besides the
|
||||
# function name, and output everything on a single line.
|
||||
_shunit_regex_='^[ ]*(function )*test[A-Za-z0-9_]* *\(\)'
|
||||
egrep "${_shunit_regex_}" "${_shunit_script_}" \
|
||||
grep -E "${_shunit_regex_}" "${_shunit_script_}" \
|
||||
|sed 's/^[^A-Za-z0-9_]*//;s/^function //;s/\([A-Za-z0-9_]*\).*/\1/g' \
|
||||
|xargs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue