I'm writing a test for a very simple local program that will read a book collection information and then print the whole list on screen. So a program run might look like this:
Title:
Romeo and Juliet
Author:
Shakespeare
ISBN:
9780199535897
Publisher:
Oxford University Press
Pages:
464
Title:
The prince
Author:
Machiavelli
ISBN:
9781545067680
Publisher:
CreateSpace Publishing
Pages:
94
======FULL LIST:======
Title: Romeo and Juliet
Author: Shakespeare
ISBN: 9780199535897
Publisher: Oxford University Press
Pages: 464
---
Title: The prince
Author: Machiavelli
ISBN: 9781545067680
Publisher: CreateSpace Publishing
Pages: 94
---
I'm using regex to ignore case in user prompts like "title" and also ignore if there are any other characters (e.g.: spaces, a colon, etc.) so the script also accepts "--Title:--" and such. I basically want to test that it's correctly storing and displaying the data I enter.
My script looks like this:
*/\n/
>./myTestProgram
<.*t|Ti|It|Tl|Le|E.*
>Romeo and Juliet
<.*a|Au|Ut|Th|Ho|Or|R.*
>Shakespeare
<.*i|Is|Sb|Bn|N.*
>9780199535897
<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*
>Oxford University Press
<.*p|Pa|Ag|Ge|Es|S.*
>464
<.*t|Ti|It|Tl|Le|E.*
>The prince
<.*a|Au|Ut|Th|Ho|Or|R.*
>Machiavelli
<.*i|Is|Sb|Bn|N.*
>9781545067680
<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*
>CreateSpace Publishing
<.*p|Pa|Ag|Ge|Es|S.*
>94
<.*
<.*t|Ti|It|Tl|Le|E.*Romeo and Juliet
<.*a|Au|Ut|To|Or|R.*Shakespeare
<.*i|Is|Sb|Bn|N.*9780199535897
<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*Oxford University Press
<.*p|Pa|Ag|Ge|Es|S.*464
<.*
<.*t|Ti|It|Tu|Ul|Lo|O.*The prince
<.*a|Au|Ut|To|Or|R.*Machiavelli
<.*i|Is|Sb|Bn|N.*9781545067680
<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*CreateSpace Publishing
<.*p|Pa|Ag|Ge|Es|S.*94
<.*
But when I run it, it fails, and using verbose mode shows it seems to not be waiting for the program output before feeding it data, so it's taking the wrong data each time:
$ ./expect-lite -c myTestProgram.elt -r Localhost -vv
expect-lite version 4.9.0
Env Vars -> Constants:
EL_CONNECT_METHOD=none
spawn bash
<<$ >>
INFO: User Defined Prompt: \n
[\u@\h:\w]\$ "
[hp@hp-HP:~/expect-lite.proj]$
[hp@hp-HP:~/expect-lite.proj]$ ./myTestProgram
find<<.*t|Ti|It|Tl|Le|E.*>>
>>in<<./myTestProgram
Romeo and Juliet
find<<.*a|Au|Ut|Th|Ho|Or|R.*>>
>>in<<Romeo and Juliet
Shakespeare
Title:
Author:
ISBN:
find<<.*i|Is|Sb|Bn|N.*>>
in<<Shakespeare
Ti>>
9780199535897
Publisher:
find<<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*>>
in<<9780199535897
Pu>>
Oxford University Press
Pages:
find<<.*p|Pa|Ag|Ge|Es|S.*>>
in<<Oxford University Press
Pa>>
464
Title:
find<<.*t|Ti|It|Tl|Le|E.*>>
in<<464
Tit>>
The prince
find<<.*a|Au|Ut|Th|Ho|Or|R.*>>
in<<Th>>
Machiavelli
find<<.*i|Is|Sb|Bn|N.*>>
in<<Machiavelli>>
9781545067680
Author:
ISBN:
Publisher:
find<<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*>>
in<<9781545067680
Author:
ISBN:
Pu>>
CreateSpace Publishing
find<<.*p|Pa|Ag|Ge|Es|S.*>>
>>in<<CreateSpace Publishing
find<<.*>>
in<<>>
94
Pages:
======FULL LIST:======:
Title: Romeo and Juliet
Author: Shakespeare
ISBN: 9780199535897
Publisher: Oxford University Press
Pages: 464
--------------
Title: The prince
Author: Machiavelli
ISBN: 9781545067680
ublisher: CreateSpace Publishing
find<<.*t|Ti|It|Tl|Le|E.*Romeo and Juliet>>
in<<94
Pages:
======FULL LIST:======:
Title: Romeo and Juliet
Author: Shakespeare
ISBN: 9780199535897
Publisher: Oxford University Press
Pages: 464
--------------
Title: The prince
Author: Machiavelli
ISBN: 9781545067680
Publisher: Creat>>
find<<.*a|Au|Ut|To|Or|R.*Shakespeare>>
in<<eSpa>>
find<<.*i|Is|Sb|Bn|N.*9780199535897>>
in<<ce Publishi>>
Pages: 94
--------------
[hp@hp-HP:~/expect-lite.proj]$
find<<.*p|Pu|Ub|Bl|Li|Is|Sh|He|Er|R.*Oxford University Press>>
in<<ng
Pages: 94
--------------
[hp@hp-HP:~/expect-lite.p>>
Waiting: ....+....
find<<.*p|Pa|Ag|Ge|Es|S.*464>>
in<<ng
Pages: 94
--------------
[hp@hp-HP:~/expect-lite.p>>
FAILED COMMAND:94
Expect Failed:.*p|Pa|Ag|Ge|Es|S.*464
exit
##Overall Result: FAILED
Any ideas on what might be the problem? Is there a way to force expect-lite to wait for the program output before it sends anything to it?
Aucun commentaire:
Enregistrer un commentaire