Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating nexpect to emit events. #19

Closed
wants to merge 1 commit into from

Conversation

gcochard
Copy link

This allows nexpect to work with conditional branching. It will emit wait right now, and the data will be the line of output which matches the expected output. From there, you can re-test the data and call sendline, expect, or wait again. Note that the user must call wait() before the end of the stackframe in which run() was called on the child.

This is a rough first draft, but it does not introduce any breaking changes as far as I can tell. All tests still pass, and the new test I have written demonstrates the new functionality. I have also added an example to the readme file.

I think this feature is critical to getting nexpect to actually act like tcl's expect. Otherwise, there is no way that I see to send different input based on the output.

This allows nexpect to work with conditional branching. It will
emit 'wait' right now, and the data will be the line of output
which matches the expected output. From there, you can re-test the data
and call sendline, expect, or wait again. Note that the user MUST
call wait BEFORE the end of the stackframe on which the child was spawned.
"and using the event driven method": {
"should respond with no error": function () {
child = nexpect.spawn('node', ['--interactive']);
child.run(function(err,stdout,exitcode){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This child.run(...) should probably be after the child.on(...) and child.wait(...), but it will work properly in either case as long as they are in the same stack frame.

@gcochard
Copy link
Author

gcochard commented May 4, 2015

Does anyone else find this change useful? Seems it might finally close #14.

@gcochard gcochard closed this May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant