fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Daniel Rainerformat: don't use tabs for indentatione0916e793

master
2.2 KiB92 linesraw
1#!/usr/bin/env python3
2from pexpect_helper import SpawnedProc, control
3
4sp = SpawnedProc()
5send, sendline, sleep, expect_prompt, expect_re, expect_str = (
6    sp.send,
7    sp.sendline,
8    sp.sleep,
9    sp.expect_prompt,
10    sp.expect_re,
11    sp.expect_str,
12)
13expect_prompt()
14
15# Verify COMPLETE_AUTO_SPACE behavior
16sendline("complete -x -c monster -a truck")
17expect_prompt()
18sendline("complete -x -c monster -a energy=")
19expect_prompt()
20send("monster t")
21sleep(0.1)
22send("\t")
23sleep(0.1)
24send("!")
25expect_str("monster truck !")  # space
26send("\b" * 64)
27send("monster e")
28sleep(0.1)
29send("\t")
30sleep(0.1)
31send("!")
32expect_str("monster energy=!")  # no space
33send("\b" * 64)
34
35sendline(
36    """
37    # Make sure this function does nothing
38    function my_is; :; end
39    complete -c my_is -n 'test (count (commandline -xpc)) = 1' -xa arg
40    complete -c my_is -n '__fish_seen_subcommand_from not' -xa '(
41    set -l cmd (commandline -xpc) (commandline -ct)
42    set cmd (string join " " my_is $cmd[3..-1])" "
43    commandline --replace --current-process $cmd
44    complete -C"$cmd"
45    )'
46"""
47)
48
49send("my_is not \t")
50send("still.alive")
51expect_re(".*still.alive")
52sendline("")
53
54# Check cancelling completion acceptance
55# (bind cancel to something else so we don't have to mess with the escape delay)
56sendline("bind ctrl-g cancel")
57sendline("complete -c echo -x -a 'foooo bar'")
58send("echo fo\t")
59send("\x07")
60sendline("bar")
61expect_re("bar")
62sendline("echo fo\t")
63expect_re("foooo")
64
65# As soon as something after the "complete" happened,
66# cancel should not undo.
67# In this case that's the space after the tab!
68send("echo fo\t ")
69send("\x07")
70sendline("bar")
71expect_re("foooo bar")
72
73sendline("bind ctrl-g 'commandline -f cancel; commandline \"\"'")
74send("echo fo\t")
75expect_re("foooo")
76send("\x07")
77sendline("echo bar")
78expect_re("\n.*bar")
79sendline("echo fo\t")
80expect_re("foooo")
81
82# Custom completions that access the command line.
83sendline("complete -e :; complete : -a '(echo (commandline -ct)-completed)'")
84send(": abcd" + control("b") * 2 + "\t")
85expect_str(": abcd-completed")
86send(control("u"))
87# Another one.
88sendline("mkdir -p foo/bar; touch foo/bar/baz.fish")
89send("source foo/b/baz.fish")
90send(control("b") * 9 + "\t")
91expect_str("source foo/bar/baz.fish")
92send(control("u"))