From d94797353b96c1151fcaa652b1fd7c7e2f990d2f Mon Sep 17 00:00:00 2001 From: anton Date: Wed, 5 Jul 2017 06:31:59 +0000 Subject: [PATCH] Add tests for file completion in ksh emacs mode, currently failing. While here, pass the v option to hexdump in order to output all data. --- regress/bin/ksh/edit/emacs.sh | 19 ++++++++++++++++++- regress/bin/ksh/edit/subr.sh | 14 +++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/regress/bin/ksh/edit/emacs.sh b/regress/bin/ksh/edit/emacs.sh index 60dbbce9457..3f88f8f7ebf 100644 --- a/regress/bin/ksh/edit/emacs.sh +++ b/regress/bin/ksh/edit/emacs.sh @@ -19,8 +19,12 @@ set -e . "${1:-.}/subr.sh" +tmp=$(mktemp -d) +trap 'rm -r $tmp' 0 +>$tmp/.profile + EDITOR= -ENV= +ENV=$tmp/.profile HISTFILE= MAIL= MALLOC_OPTIONS=S @@ -91,3 +95,16 @@ testseq "z\0002\0364\0277\0277\0277" \ # insertion of unmatched meta sequence testseq "z\0002\0033[3z" " $ z\b\0007" + +# file completion +echo "cd $tmp" >$tmp/.profile +mkdir -p \ + $tmp/a/a{1,2} $tmp/b\ b/b{1,2} $tmp/\(ccc\)/c{1,2} $tmp/\(d\ d\)/d{1,2} +testseq "cd a/\t" \ + " $ cd a/\b\b \b\b\r $ cd a/a$(genseq 70 " " "\b")\r $ cd a/a \b" +testseq "cd b\ b/\t" \ + " $ cd b\ b/$(genseq 5 "\b" " " "\b")\r $ cd b\ b/b$(genseq 67 " " "\b")\r $ cd b\ b/b \b" +testseq "cd \(ccc\)/\t" \ + " $ cd \(ccc\)/$(genseq 8 "\b" " " "\b")\r $ cd \(ccc\)/c$(genseq 64 " " "\b")\r $ cd \(ccc\)/c \b" +testseq "cd \(d\ d\)/\t" \ + " $ cd \(d\ d\)/$(genseq 9 "\b" " " "\b")\r $ cd \(d\ d\)/d$(genseq 63 " " "\b")\r $ cd \(d\ d\)/d \b" diff --git a/regress/bin/ksh/edit/subr.sh b/regress/bin/ksh/edit/subr.sh index fb027c4e885..1b29582282d 100644 --- a/regress/bin/ksh/edit/subr.sh +++ b/regress/bin/ksh/edit/subr.sh @@ -13,6 +13,14 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +genseq() { + n=$1 + while [ $# -ge 1 ]; do + shift + jot -n -b "$1" -s '' "$n" + done +} + testseq() { stdin=$1 exp=$(echo "$2") @@ -21,13 +29,13 @@ testseq() { echo input: echo ">>>$stdin<<<" - echo -n "$stdin" | hexdump -C + echo -n "$stdin" | hexdump -Cv echo expected: echo ">>>$exp<<<" - echo -n "$exp" | hexdump -C + echo -n "$exp" | hexdump -Cv echo actual: echo ">>>$act<<<" - echo -n "$act" | hexdump -C + echo -n "$act" | hexdump -Cv return 1 } -- 2.20.1