mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
Add eval recursion overflow regression test
This particular variant must be executed as a pexpect test since it relies on the interactive-only `$history` to trigger the recursion. Note that recursion is possible via other means (e.g. reading/writing a file), the usage of history here is just one such example.
This commit is contained in:
parent
3913b28153
commit
2c870b305d
34
tests/pexpects/eval-stack-overflow.py
Normal file
34
tests/pexpects/eval-stack-overflow.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pexpect_helper import SpawnedProc
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sp = SpawnedProc()
|
||||||
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
||||||
|
sp.send,
|
||||||
|
sp.sendline,
|
||||||
|
sp.sleep,
|
||||||
|
sp.expect_prompt,
|
||||||
|
sp.expect_re,
|
||||||
|
sp.expect_str,
|
||||||
|
)
|
||||||
|
expect_prompt()
|
||||||
|
|
||||||
|
sendline("echo cat dog")
|
||||||
|
expect_prompt("cat dog")
|
||||||
|
|
||||||
|
sendline("eval (string replace dog tiger -- $history[1])")
|
||||||
|
expect_prompt("cat tiger")
|
||||||
|
|
||||||
|
sendline("eval (string replace dog tiger -- $history[1])")
|
||||||
|
expect_re("fish: The call stack limit has been exceeded.*"
|
||||||
|
+ "\r\nin command substitution"
|
||||||
|
+ "\r\nfish: Unable to evaluate string substitution"
|
||||||
|
+ re.escape("\r\neval (string replace dog tiger -- $history[1])")
|
||||||
|
+ "\r\n *\^~+\^\w*")
|
||||||
|
expect_prompt()
|
||||||
|
|
||||||
|
sendline("\x04") # <c-d>
|
||||||
|
sys.exit(0)
|
Loading…
x
Reference in New Issue
Block a user