Skip to content

Commit

Permalink
Add a test for the "load" command
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Dec 8, 2024
1 parent 3fc8fea commit a0090c0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
dnl Process this file with autoconf to produce a configure script.

# Copyright (C) 2002-2012,
# 2014-2019, 2023 Rocky Bernstein <rocky@gnu.org>
# 2014-2019, 2023-2024 Rocky Bernstein <rocky@gnu.org>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -231,6 +231,8 @@ AC_CONFIG_FILES([test/unit/test-cmd-info-variables.sh],
[chmod +x test/unit/test-cmd-info-variables.sh])
AC_CONFIG_FILES([test/unit/test-cmd-eval.sh],
[chmod +x test/unit/test-cmd-eval.sh])
AC_CONFIG_FILES([test/unit/test-cmd-load.sh],
[chmod +x test/unit/test-cmd-load.sh])
AC_CONFIG_FILES([test/unit/test-columns.sh],
[chmod +x test/unit/test-columns.sh])
AC_CONFIG_FILES([test/unit/test-file.sh],
Expand Down
5 changes: 3 additions & 2 deletions test/unit/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*~
/*.trs
/*.log
/*.trs
/*~
/Makefile
/Makefile.in
/require_me.sh
Expand All @@ -11,6 +11,7 @@
/test-cmd-complete.sh
/test-cmd-eval.sh
/test-cmd-info-variables.sh
/test-cmd-load.sh
/test-columns.sh
/test-eval.sh
/test-file.sh
Expand Down
1 change: 1 addition & 0 deletions test/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ TESTS = test-action.sh \
test-cmd-complete.sh \
test-cmd-eval.sh \
test-cmd-info-variables.sh \
test-cmd-load.sh \
test-columns.sh \
test-filecache.sh \
test-file.sh \
Expand Down
37 changes: 37 additions & 0 deletions test/unit/test-cmd-load.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!@SH_PROG@
# -*- shell-script -*-

typeset -a messages=()

test_cmd_load()
{
# Check that load_file caches mapping from short name
# to fully-resolved file name
local find_file="./test-cmd-load.sh.in"
cd $(dirname ${BASH_SOURCE[0]})
_Dbg_init_cwd=$(pwd)
_Dbg_do_load "$find_file"
assertEquals ${#messages[@]} 0
typeset cached_file="${_Dbg_file2canonic[$find_file]}"
assertEquals "$cached_file" $(_Dbg_resolve_expand_filename "$find_file")
}

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
for file in alias help fns ; do
. ${abs_top_srcdir}lib/${file}.sh
done
. ${abs_top_srcdir}lib/filecache.sh
. ${abs_top_srcdir}lib/file.sh
. ${abs_top_srcdir}lib/unescape.sh
. ${abs_top_srcdir}command/load.sh
set -- # reset $# so shunit2 doesn't get confused.
[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}

# Replace lib/msg _Dbg_msg with sothing to track.
function _Dbg_msg {
messages+=("$@)
}

0 comments on commit a0090c0

Please sign in to comment.