From 7076880da911d358ed3d025f28a6241c34d840f8 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 8 Jun 2020 17:08:48 +0200 Subject: [PATCH] Move commandline test to pexpect --- tests/commandline.expect | 30 ------------------------------ tests/commandline.expect.err | 0 tests/commandline.expect.out | 8 -------- tests/pexpects/commandline.py | 21 +++++++++++++++++++++ 4 files changed, 21 insertions(+), 38 deletions(-) delete mode 100644 tests/commandline.expect delete mode 100644 tests/commandline.expect.err delete mode 100644 tests/commandline.expect.out create mode 100644 tests/pexpects/commandline.py diff --git a/tests/commandline.expect b/tests/commandline.expect deleted file mode 100644 index 8db0c8331..000000000 --- a/tests/commandline.expect +++ /dev/null @@ -1,30 +0,0 @@ -# vim: set filetype=expect: - -spawn $fish - -expect_prompt - -send_line "bind '~' 'handle_tilde'" -expect_prompt - -# printing the current buffer should not remove quoting -send_line "function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end" -expect_prompt -send_line {echo \en one "two three" four'five six'{7} 'eight~} -expect_prompt -re {\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n} { - puts "a:" - puts $expect_out(1,string) -} unmatched { - abort "Couldn't find guard 1" -} - -# printing the buffer with -o should remove quoting -send_line "function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end" -expect_prompt -send_line {echo one "two three" four'five six'{7} 'eight~} -expect_prompt -re {\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n} { - puts "b:" - puts [string map {\r {}} $expect_out(1,string)] -} unmatched { - abort "Couldn't find guard 2" -} diff --git a/tests/commandline.expect.err b/tests/commandline.expect.err deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/commandline.expect.out b/tests/commandline.expect.out deleted file mode 100644 index ea3879a83..000000000 --- a/tests/commandline.expect.out +++ /dev/null @@ -1,8 +0,0 @@ -a: -echo \en one "two three" four'five six'{7} 'eight -b: -echo -one -two three -fourfive six{7} -eight diff --git a/tests/pexpects/commandline.py b/tests/pexpects/commandline.py new file mode 100644 index 000000000..5d12f68de --- /dev/null +++ b/tests/pexpects/commandline.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +from pexpect_helper import SpawnedProc + +sp = SpawnedProc() +send, sendline, sleep, expect_prompt = sp.send, sp.sendline, sp.sleep, sp.expect_prompt +expect_prompt() + +sendline("bind '~' 'handle_tilde'") +expect_prompt() + +# printing the current buffer should not remove quoting +sendline("function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end") +expect_prompt() +sendline ("echo \en one \"two three\" four'five six'{7} 'eight~") +expect_prompt("\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n") + +# printing the buffer with -o should remove quoting +sendline("function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end") +expect_prompt() +sendline("echo one \"two three\" four'five six'{7} 'eight~") +expect_prompt("\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n")