mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Fix flaky special char specs by not using with_history
twice per test
There's something funny occasionally happening when `with_history` is used twice in the same test. It seems to be happening more frequently since asynchronous mode was enabled by default. My guess is it has something to do with the `C-c` keys being sent toward the end not consistently terminating the prompt. But I'm really not sure how it would ever get into a `then` block like it seems to: ``` Failure/Error: wait_for { session.content }.to eq('echo "hello\nworld"') expected: "echo \"hello\\nworld\"" got: "then> echo \"hello\\" ``` Sticking to only one `with_history` per terminal session (per test) seems to fix the flakiness. I also removed an old test case because I could not understand why it was necessary and so couldn't write a good description for it. Could be we'll need to add it back in at some point.
This commit is contained in:
parent
e715ffb1ae
commit
05f22fa8a3
1 changed files with 20 additions and 7 deletions
|
@ -1,58 +1,71 @@
|
||||||
shared_examples 'special characters' do
|
shared_examples 'special characters' do
|
||||||
describe 'a special character in the buffer' do
|
describe 'a special character in the buffer should be treated like any other character' do
|
||||||
it 'should be treated like any other character' do
|
it 'asterisk' do
|
||||||
with_history('echo "hello*"', 'echo "hello."') do
|
with_history('echo "hello*"', 'echo "hello."') do
|
||||||
session.send_string('echo "hello*')
|
session.send_string('echo "hello*')
|
||||||
wait_for { session.content }.to eq('echo "hello*"')
|
wait_for { session.content }.to eq('echo "hello*"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'question mark' do
|
||||||
with_history('echo "hello?"', 'echo "hello."') do
|
with_history('echo "hello?"', 'echo "hello."') do
|
||||||
session.send_string('echo "hello?')
|
session.send_string('echo "hello?')
|
||||||
wait_for { session.content }.to eq('echo "hello?"')
|
wait_for { session.content }.to eq('echo "hello?"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'backslash' do
|
||||||
with_history('echo "hello\nworld"') do
|
with_history('echo "hello\nworld"') do
|
||||||
session.send_string('echo "hello\\')
|
session.send_string('echo "hello\\')
|
||||||
wait_for { session.content }.to eq('echo "hello\nworld"')
|
wait_for { session.content }.to eq('echo "hello\nworld"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'double backslash' do
|
||||||
with_history('echo "\\\\"') do
|
with_history('echo "\\\\"') do
|
||||||
session.send_string('echo "\\\\')
|
session.send_string('echo "\\\\')
|
||||||
wait_for { session.content }.to eq('echo "\\\\"')
|
wait_for { session.content }.to eq('echo "\\\\"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'tilde' do
|
||||||
with_history('echo ~/foo') do
|
with_history('echo ~/foo') do
|
||||||
session.send_string('echo ~')
|
session.send_string('echo ~')
|
||||||
wait_for { session.content }.to eq('echo ~/foo')
|
wait_for { session.content }.to eq('echo ~/foo')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'parentheses' do
|
||||||
with_history('echo "$(ls foo)"') do
|
with_history('echo "$(ls foo)"') do
|
||||||
session.send_string('echo "$(')
|
session.send_string('echo "$(')
|
||||||
wait_for { session.content }.to eq('echo "$(ls foo)"')
|
wait_for { session.content }.to eq('echo "$(ls foo)"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'square bracket' do
|
||||||
with_history('echo "$history[123]"') do
|
with_history('echo "$history[123]"') do
|
||||||
session.send_string('echo "$history[')
|
session.send_string('echo "$history[')
|
||||||
wait_for { session.content }.to eq('echo "$history[123]"')
|
wait_for { session.content }.to eq('echo "$history[123]"')
|
||||||
session.send_string('123]')
|
session.send_string('123]')
|
||||||
wait_for { session.content }.to eq('echo "$history[123]"')
|
wait_for { session.content }.to eq('echo "$history[123]"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'octothorpe' do
|
||||||
with_history('echo "#yolo"') do
|
with_history('echo "#yolo"') do
|
||||||
session.send_string('echo "#')
|
session.send_string('echo "#')
|
||||||
wait_for { session.content }.to eq('echo "#yolo"')
|
wait_for { session.content }.to eq('echo "#yolo"')
|
||||||
end
|
end
|
||||||
|
|
||||||
with_history('echo "#foo"', 'echo $#abc') do
|
|
||||||
session.send_string('echo "#')
|
|
||||||
wait_for { session.content }.to eq('echo "#foo"')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'caret' do
|
||||||
with_history('echo "^A"', 'echo "^B"') do
|
with_history('echo "^A"', 'echo "^B"') do
|
||||||
session.send_string('echo "^A')
|
session.send_string('echo "^A')
|
||||||
wait_for { session.content }.to eq('echo "^A"')
|
wait_for { session.content }.to eq('echo "^A"')
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'dash' do
|
||||||
with_history('-foo() {}') do
|
with_history('-foo() {}') do
|
||||||
session.send_string('-')
|
session.send_string('-')
|
||||||
wait_for { session.content }.to eq('-foo() {}')
|
wait_for { session.content }.to eq('-foo() {}')
|
||||||
|
|
Loading…
Reference in a new issue