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

Need better interactive test driver #5451

Closed
mqudsi opened this issue Dec 31, 2018 · 6 comments
Closed

Need better interactive test driver #5451

mqudsi opened this issue Dec 31, 2018 · 6 comments

Comments

@mqudsi
Copy link
Contributor

mqudsi commented Dec 31, 2018

I have a series of tests that I keep in my head and run manually when testing job control. I can't use the existing testing framework for these because it's incapable of interacting with child processes in any of the modes (C++, fish script, or expect).

As the simplest example, we need a scripted way to do this in an interactive fish session:

  • Run fish
  • Start foo | less
  • Send ^Z to the foreground job
  • Run a fish command and error if we hang here

Any suggestions on how this might be accomplished? The Tcl/expect scripts can't do the first bolded step, or at least, I can't figure out how to get them to do it. Input seems to always be directed either to the (local) console or to fish itself, but does not reach child procs.

@zanchey zanchey added this to the fish-future milestone Jan 2, 2019
@zanchey
Copy link
Member

zanchey commented Jan 2, 2019

Can you signal the process rather than sending Ctrl-Z?

@mqudsi
Copy link
Contributor Author

mqudsi commented Jan 4, 2019

@zanchey good suggestion, but I don't think so since that would require some form of backgrounding in order to get the fish instance to return $last_pid and to send the signal while less is in the foreground. Additionally, for testing the most basic assumptions of job control depending on complex bg/fg behavior and executing multiple jobs at once is probably not the way to go.

In all cases, that was just an example of something I needed to do. There are cases where it's necessary to do other things, such as verify that stdin is correctly connected to the right job, etc.

@mqudsi mqudsi changed the title Need better test driver Need better interactive test driver Jan 4, 2019
@faho
Copy link
Member

faho commented Jul 20, 2020

Okay, we have pexpect now which is nicer to work with than expect, because it's now python rather than tcl.

I'm calling that good enough for now.

@faho faho closed this as completed Jul 20, 2020
@faho faho modified the milestones: fish-future, fish 3.2.0 Jul 20, 2020
@zanchey
Copy link
Member

zanchey commented Jul 21, 2020

Can we implement @mqudsi's tests above now?

@faho
Copy link
Member

faho commented Jul 21, 2020

Something like

sendline("cat | cat")
sendline("foo")
expect_str("foo")
sendline("set -l foo bar; echo $foo")
expect_str("set -l foo bar; echo $foo")
send("\x1A")
sendline("set -l foo bar; echo $foo")
expect_str("bar")
expect_prompt()

should do? It seems to work in my tests - The fish script before the \x1A (ctrl-z) and comes back literally, and the script after is interpreted.

faho added a commit that referenced this issue Jul 21, 2020
@mqudsi
Copy link
Contributor Author

mqudsi commented Jul 26, 2020

Indeed, that looks great!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants