Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Regularize unit tests to make reuse easier between kshdb, zshdb and b…

…ashdb.
  • Loading branch information...
commit 5695ecd1cb94d1c0bdcf81d8d3e8fcc3e6cad046 1 parent 2d36eb7
@rocky authored
View
1  command/trace.sh
@@ -43,6 +43,7 @@ function _Dbg_do_trace {
return 3
}
cmd=$(typeset -f -- "$fn") || {
+ _Dbg_errmsg "trace: Can't get function definition for \"$fn\"."
return 4
}
if [[ $cmd =~ '^function ' ]] ; then
View
3  configure.ac
@@ -16,6 +16,9 @@ fi
AC_SUBST(DIFF)
AC_SUBST(DIFF_OPTS)
+CMDLINE_INVOKED='${0##*/} == ${.sh.file##*/}'
+AC_SUBST(CMDLINE_INVOKED)
+
## --with-ksh can be used to tell the kshdb script and the regression
## test which ksh to run. It can be omitted too in which case we'll
## look for a ksh binary.
View
9 test/unit/test-alias.sh.in
@@ -29,23 +29,18 @@ test_alias()
assertEquals 'up' $expanded_alias
}
-# Make sure @top_builddir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
echo "Something is wrong abs_top_srcdir is not set."
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @abs_top_srcr@ has a trailing slash
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/lib/alias.sh
. $abs_top_srcdir/lib/help.sh
. $abs_top_srcdir/lib/run.sh
. $abs_top_srcdir/command/alias.sh
set --
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
11 test/unit/test-break.sh.in
@@ -95,13 +95,13 @@ test_breakpoint()
assertEquals 0 $_Dbg_brkpt_count
}
-# Make sure @top_builddir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
echo "Something is wrong abs_top_srcdir is not set."
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
@@ -111,11 +111,4 @@ abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}lib/break.sh
set -- # reset $# so shunit2 doesn't get confused.
-srcdir=.
-srcdir=${srcdir%%/}/
-
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
8 test/unit/test-cmd-complete.sh.in
@@ -15,10 +15,9 @@ if [ '@abs_top_srcdir@' = '' ] ; then
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @abs_top_srcr@ has a trailing slash
+# Make sure @abs_top_srcrdir@ has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. ${abs_top_srcdir}lib/alias.sh
. ${abs_top_srcdir}lib/help.sh
. ${abs_top_srcdir}lib/msg.sh
@@ -30,7 +29,4 @@ for _Dbg_file in ${abs_top_srcdir}command/d*.sh ; do
source $_Dbg_file
done
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-columns.sh.in
@@ -34,19 +34,14 @@ test_columnized()
}
-# Make sure @top_builddir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
echo "Something is wrong abs_top_srcdir is not set."
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/lib/columnize.sh
set --
-
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
8 test/unit/test-dbg-opts.sh.in
@@ -62,11 +62,7 @@ if [ '@abs_top_srcdir@' = '' ] ; then
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @top_srcdir@ has a trailing slash
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-eval.sh.in
@@ -45,15 +45,10 @@ test_eval_subst()
}
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_builddir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
-srcdir=@srcdir@
-srcdir=${srcdir%%/}/
. $abs_top_srcdir/lib/fns.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
8 test/unit/test-examine.sh.in
@@ -55,9 +55,9 @@ test_examine()
}
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. ${abs_top_srcdir}lib/fns.sh
. ${abs_top_srcdir}lib/msg.sh
. ${abs_top_srcdir}lib/help.sh
@@ -66,8 +66,4 @@ abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}command/examine.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
15 test/unit/test-file.sh.in
@@ -6,14 +6,15 @@ test_file_glob_filename()
typeset filename
filename=''
_Dbg_glob_filename $shunit_file
- assertEquals '0' $?
+ assertEquals "Should be able to glob $shunit_file" '0' $?
filename=${filename##*/}
assertEquals 'shunit2' $filename
+
_Dbg_glob_filename ./${srcdir}shunit?
assertEquals '0' $?
filename=${filename##*/}
assertEquals 'shunit2' $filename
- _Dbg_glob_filename ${srcdir}abcdefg
+ _Dbg_glob_filename ${abs_top_srcdir}abcdefg
assertEquals '1' $?
filename=${filename##*/}
assertEquals 'abcdefg' $filename
@@ -51,21 +52,15 @@ test_file_resolve_expand_filename()
}
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/init/pre.sh
. $abs_top_srcdir/lib/filecache.sh
. $abs_top_srcdir/lib/file.sh
set -- # reset $# so shunit2 doesn't get confused.
-SHUNIT_PARENT=$0
-
srcdir=@srcdir@
srcdir=${srcdir%%/}/
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-filecache.sh.in
@@ -43,23 +43,18 @@ test_filecache_check_line()
_Dbg_check_line 10000 $shunit_file
}
-# Make sure @top_builddir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
echo "Something is wrong abs_top_srcdir is not set."
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. ${abs_top_srcdir}init/pre.sh
. ${abs_top_srcdir}lib/filecache.sh
. ${abs_top_srcdir}lib/file.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
7 test/unit/test-fns.sh.in
@@ -117,15 +117,10 @@ test_fns_split()
abs_top_srcdir=@abs_top_srcdir@
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/init/pre.sh
. $abs_top_srcdir/lib/msg.sh
. $abs_top_srcdir/lib/fns.sh
. $abs_top_srcdir/lib/frame.sh
. $abs_top_srcdir/lib/journal.sh
set -- # reset $# so shunit2 doesn't get confused.
-
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
10 test/unit/test-frame.sh.in
@@ -45,21 +45,15 @@ test_frame_adjust()
done
}
-# Make sure @top_builddir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
echo "Something is wrong abs_top_srcdir is not set."
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/lib/frame.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-srcdir=@srcdir@
-srcdir=${srcdir}/
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
8 test/unit/test-get-sourceline.sh.in
@@ -3,7 +3,7 @@
this_script=test-get-sourceline.sh
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @abs_top_srcdir@ has a trailing slash
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
# Test _Dbg_get_source_line
@@ -44,8 +44,4 @@ fi
. ${abs_top_srcdir}lib/msg.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
11 test/unit/test-journal.sh.in
@@ -28,24 +28,17 @@ test_journal()
assertEquals 0 "$?"
}
-
-# Make sure @abs_top_srcdir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
echo "Something is wrong: abs_top_srcdir is not set."
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/init/pre.sh
. $abs_top_srcdir/lib/journal.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-srcdir=@srcdir@
-srcdir=${srcdir%%/}/
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${srcdir}shunit2
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
7 test/unit/test-lib-complete.sh.in
@@ -17,13 +17,10 @@ if [ '@abs_top_srcdir@' = '' ] ; then
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @abs_top_srcr@ has a trailing slash
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}lib/complete.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
7 test/unit/test-msg.sh.in
@@ -27,13 +27,10 @@ test_msg_undefined()
}
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}lib/msg.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-pre.sh.in
@@ -30,15 +30,10 @@ test_pre_do_show_version()
}
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}/init/pre.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-srcdir=@srcdir@
-srcdir=${srcdir}/
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${srcdir}/shunit2
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
8 test/unit/test-run.sh.in
@@ -17,14 +17,10 @@ test_run_not_running()
}
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}/lib/run.sh
set -- # reset $# so shunit2 doesn't get confused.
-srcdir=@srcdir@
-srcdir=${srcdir}/
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-save-restore.sh.in
@@ -19,18 +19,13 @@ test_save_restore_IFS_PS4()
IFS="$old_IFS"
}
-# Make sure ../.. has a trailing slash
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/init/pre.sh
. $abs_top_srcdir/lib/journal.sh
. $abs_top_srcdir/lib/save-restore.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-setshow.sh.in
@@ -24,15 +24,10 @@ if [ '@abs_top_srcdir@' = '' ] ; then
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
+# Make sure $abs_top_srcdir a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}lib/setshow.sh
set -- # reset $# so shunit2 doesn't get confused.
-srcdir=@srcdir@
-srcdir=${srcdir}/
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
-
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
9 test/unit/test-sort.sh.in
@@ -40,15 +40,10 @@ if [ '@abs_top_srcdir@' = '' ] ; then
exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @abs_top_srcr@ has a trailing slash
+# Make sure $abs_top_srcr has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}/lib/sort.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-srcdir=@srcdir@
-srcdir=${srcdir}/
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
View
12 test/unit/test-tty.sh.in
@@ -4,8 +4,8 @@ typeset -a _Dbg_fd=(1)
test_tty()
{
- _Dbg_open_if_tty $0
- assertEquals "1" "$?"
+ _Dbg_open_if_tty test-tty.sh
+ assertEquals "should be able to open test-tty.sh" "1" "$?"
assertEquals "-1" "$_Dbg_new_fd"
tty=$(tty)
if (($? == 0)); then
@@ -34,14 +34,10 @@ if [ '@abs_top_srcdir@' = '' ] ; then
fi
abs_top_srcdir=@abs_top_srcdir@
-# Make sure @abs_top_srcdir@ has a trailing slash
+# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
-
. $abs_top_srcdir/lib/tty.sh
set -- # reset $# so shunit2 doesn't get confused.
-# load shunit2
-if [[ ${0##*/} == ${.sh.file##*/} ]] ; then
- . ${shunit_file}
-fi
+[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
Please sign in to comment.
Something went wrong with that request. Please try again.