This repository has been archived by the owner on Sep 21, 2023. It is now read-only.
forked from ThomasRooney/gexpect
-
Notifications
You must be signed in to change notification settings - Fork 10
Merge changes from upstream #5
Merged
jonboulle
merged 16 commits into
coreos:master
from
kinvolk-archives:krnowak/merge-upstream-changes2
Mar 31, 2016
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9280703
Fix buffer corruption in ReadUntil
ee8ae05
Add function ExpectRegexFindWithOutput
steveej 7cc61e4
Add function ExpectTimeoutRegexFindWithOutput
steveej 49dbcc3
Rewrite imports due to fork
steveej dc2df9d
tests: minor fixes
steveej 50ed6be
Increased error message detail
steveej d2847a3
tests: fix typo in error message
steveej ac5ac7d
include output in the error when a timeout occurs
alban 3068b6f
examples: fix import references
jonboulle d2cbfdc
Put the excess unmatched characters back into the buffer
krnowak 57a64e8
Add a test for putting the excess characters back into the buffer
krnowak fe0fad0
Reset the import bindings on the examples to the original repository
ThomasRooney 3841f9c
Fix issue with swallowing final line of output. Fix test to use print…
ThomasRooney 36998b8
Fix buffer corruption in Expect
d4dfd2e
Merge pull request #20 from heyitsanthony/fix-expect
ThomasRooney 2ea7406
Merge remote-tracking branch 'upstream/master'
krnowak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,6 +188,31 @@ func TestRegexFind(t *testing.T) { | |
} | ||
} | ||
|
||
func TestReadLine(t *testing.T) { | ||
t.Logf("Testing ReadLine...") | ||
|
||
child, err := Spawn("echo \"foo\nbar\"") | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
s, err := child.ReadLine() | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if s != "foo\r" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does it expect "\r" if the command prints "\n"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My earlier experiments shown that lines read from pty always end in \r\n. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment above was a bit too short - they end in \r\n and ReadLine reads pty until it finds \n, so it returns a line ending with \r. |
||
t.Fatalf("expected 'foo\\r', got '%s'", s) | ||
} | ||
s, err = child.ReadLine() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if s != "bar\r" { | ||
t.Fatalf("expected 'bar\\r', got '%s'", s) | ||
} | ||
} | ||
|
||
func TestRegexWithOutput(t *testing.T) { | ||
t.Logf("Testing Regular Expression search with output...") | ||
|
||
|
@@ -257,7 +282,7 @@ func TestRegexTimeoutWithOutput(t *testing.T) { | |
|
||
func TestRegexFindNoExcessBytes(t *testing.T) { | ||
t.Logf("Testing Regular Expressions returning output with no excess strings") | ||
repeats := 100 | ||
repeats := 50 | ||
tests := []struct { | ||
desc string | ||
loopBody string | ||
|
@@ -284,7 +309,7 @@ func TestRegexFindNoExcessBytes(t *testing.T) { | |
}, | ||
{ | ||
desc: `matching chunks in single line chunk by chunk`, | ||
loopBody: `echo -n "a ${i} b"`, | ||
loopBody: `printf "a ${i} b"`, | ||
searchPattern: `a\s+(\d+)\s+b`, | ||
expectFullTmpl: `a %d b`, | ||
unmatchedData: "", | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you do the same kind of changes in
Expect()
, line 320?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno, it is not a change I have made, just some fix from upstream. But probably yes, would need a test for it to know.