From 7d2346bda33e054df5c637d30317c2370a10770f Mon Sep 17 00:00:00 2001 From: Jiri Kucera Date: Wed, 8 Jul 2020 12:57:30 +0200 Subject: [PATCH] tests: Scope Command & co. to RunCmdViaExpect --- tests/utils/rlwrap.sh | 58 +++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/tests/utils/rlwrap.sh b/tests/utils/rlwrap.sh index c11b7d7..dd9b97b 100644 --- a/tests/utils/rlwrap.sh +++ b/tests/utils/rlwrap.sh @@ -255,53 +255,61 @@ function RunCmdViaExpect() { _rlwrap_expect_script_input_args=() _rlwrap_rlRun_status="0" _rlwrap_rlRun_comment="" + + alias Path=_rlwrap_Path + alias rlRunOptions=_rlwrap_rlRunOptions + alias ExpectOptions=_rlwrap_ExpectOptions + alias Command=_rlwrap_Command + alias Input=_rlwrap_Input + alias Status=_rlwrap_Status + alias Comment=_rlwrap_Comment } ## -# Path [PATH] +# _rlwrap_Path [PATH] # # PATH # PATH to script directory # -# See RunCmdViaExpect. -function Path() { +# See Path in RunCmdViaExpect. +function _rlwrap_Path() { if [[ $# -gt 0 ]]; then _rlwrap_expect_script_path="${1}" fi } ## -# rlRunOptions [OPTIONS] +# _rlwrap_rlRunOptions [OPTIONS] # # OPTIONS # options for rlRun # -# See RunCmdViaExpect. -function rlRunOptions() { +# See rlRunOptions in RunCmdViaExpect. +function _rlwrap_rlRunOptions() { _rlwrap_rlRun_options+=( "$@" ) } ## -# ExpectOptions [OPTIONS] +# _rlwrap_ExpectOptions [OPTIONS] # # OPTIONS # options for expect tool # -# See RunCmdViaExpect. -function ExpectOptions() { +# See ExpectOptions in RunCmdViaExpect. +function _rlwrap_ExpectOptions() { _rlwrap_expect_options+=( "$@" ) } ## -# Command [COMMAND_OR_OPTION] [COMMAND_OPTIONS] +# _rlwrap_Command [COMMAND_OR_OPTION] [COMMAND_OPTIONS] # # COMMAND_OR_OPTION # command name or option (depending on a number of Command invocations) # COMMAND_OPTIONS # command options # -# See RunCmdViaExpect. -function Command() { +# See Command in RunCmdViaExpect. +function _rlwrap_Command() { if [[ -z "${_rlwrap_expect_script}" ]]; then if [[ -n "${1:-}" ]]; then _rlwrap_expect_script="${1}.exp" @@ -317,38 +325,38 @@ function Command() { } ## -# Input [OPTIONS] +# _rlwrap_Input [OPTIONS] # # OPTIONS # options for expect script that are used for passing input values to # commands that are run from within the script # -# See RunCmdViaExpect. -function Input() { +# See Input in RunCmdViaExpect. +function _rlwrap_Input() { _rlwrap_expect_script_input_args+=( "$@" ) } ## -# Status [STATUS_CODE] +# _rlwrap_Status [STATUS_CODE] # # STATUS_CODE # expected status/return code of expect script # -# See RunCmdViaExpect. -function Status() { +# See Status in RunCmdViaExpect. +function _rlwrap_Status() { if [[ $# -gt 0 ]]; then _rlwrap_rlRun_status="${1}" fi } ## -# Comment [COMMENT] +# _rlwrap_Comment [COMMENT] # # COMMENT # comment to be passed to rlRun # -# See RunCmdViaExpect. -function Comment() { +# See Comment in RunCmdViaExpect. +function _rlwrap_Comment() { if [[ $# -gt 0 ]]; then _rlwrap_rlRun_comment="${1}" fi @@ -361,6 +369,14 @@ function Comment() { function FinishRun() { local __command="" + unalias Path + unalias rlRunOptions + unalias ExpectOptions + unalias Command + unalias Input + unalias Status + unalias Comment + if [[ -z "${_rlwrap_expect_script}" ]]; then errmsg "RunCmdViaExpect: Missing name of expect script!" errmsg "| The name of expect script is deduced from the first"