-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Wait to wait for expected output (#257)
* add Match and MatchAny commands * allow changing Match value * switch to MatchLine and MatchScreen * remove leftover code * add wait and regex to lexer * add parseWait * Add wait option defaults * add execute for wait * allow setting WAitTimeout and WaitPattern * remove MATCH_LINE and MATCH_SCREEN * add description to Buffer method * add wait to parser test and fix setting parsing * update TestCommand * improve error output for Wait timeout * don't require regex (fall back to WaitPattern) * update signatures with errors * set default wait timeout to 15s * Update testing.go Co-authored-by: Christian Rocha <[email protected]> --------- Co-authored-by: Christian Rocha <[email protected]>
- Loading branch information
1 parent
a6c47c8
commit 9624cda
Showing
12 changed files
with
252 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import ( | |
func TestParser(t *testing.T) { | ||
input := ` | ||
Set TypingSpeed 100ms | ||
Set WaitTimeout 1m | ||
Set WaitPattern /foo/ | ||
Type "echo 'Hello, World!'" | ||
Enter | ||
[email protected] 5 | ||
|
@@ -28,10 +30,15 @@ Ctrl+C | |
Ctrl+L | ||
Alt+. | ||
Sleep 100ms | ||
Sleep 3` | ||
Sleep 3 | ||
Wait | ||
Wait+Screen | ||
Wait@100ms /foobar/` | ||
|
||
expected := []Command{ | ||
{Type: token.SET, Options: "TypingSpeed", Args: "100ms"}, | ||
{Type: token.SET, Options: "WaitTimeout", Args: "1m"}, | ||
{Type: token.SET, Options: "WaitPattern", Args: "foo"}, | ||
{Type: token.TYPE, Options: "", Args: "echo 'Hello, World!'"}, | ||
{Type: token.ENTER, Options: "", Args: "1"}, | ||
{Type: token.BACKSPACE, Options: "0.1s", Args: "5"}, | ||
|
@@ -49,6 +56,9 @@ Sleep 3` | |
{Type: token.ALT, Options: "", Args: "."}, | ||
{Type: token.SLEEP, Args: "100ms"}, | ||
{Type: token.SLEEP, Args: "3s"}, | ||
{Type: token.WAIT, Args: "Line"}, | ||
{Type: token.WAIT, Args: "Screen"}, | ||
{Type: token.WAIT, Options: "100ms", Args: "Line foobar"}, | ||
} | ||
|
||
l := lexer.New(input) | ||
|
@@ -57,7 +67,7 @@ Sleep 3` | |
cmds := p.Parse() | ||
|
||
if len(cmds) != len(expected) { | ||
t.Fatalf("Expected %d commands, got %d", len(expected), len(cmds)) | ||
t.Fatalf("Expected %d commands, got %d; %v", len(expected), len(cmds), cmds) | ||
} | ||
|
||
for i, cmd := range cmds { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.