Permalink
Browse files

more tests

  • Loading branch information...
1 parent 80dd2c1 commit 4882f21e1a37d762e284faff6678983dd8a8d008 @chipaca chipaca committed Nov 28, 2016
@@ -1,3 +1,4 @@
+# -*- sh -*-
_complete() {
local cur prev words cword
_init_completion || return
@@ -23,7 +24,10 @@ _complete() {
case $command in
install|info|sign-build)
- _filedir "*.snap"
+ _filedir "snap"
+ ;;
+ ack)
+ _filedir
;;
try)
_filedir -d
@@ -0,0 +1,7 @@
+source lib.exp0
+
+# abort completes with change ids
+rechat "snap abort \t\t" "1 *2"
+
+cancel
+brexit
@@ -0,0 +1,8 @@
+source lib.exp0
+
+# ack completes with directories and files
+chat "snap ack ./\t\t" "ack.exp" true
+chat "" " testdir/"
+
+cancel
+brexit
@@ -0,0 +1,8 @@
+source lib.exp0
+
+# buy completes remote snaps only
+chat "snap buy \t\t" "snap buy ??$"
+chat "test-\t\t" "test-assumes*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,7 @@
+source lib.exp0
+
+# change completes with change ids
+rechat "snap change \t\t" "1 *2"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap delete-key \t" "snap delete-key default"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap disable \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,7 @@
+source lib.exp0
+
+# download with 3+ chars completes store stuff
+chat "snap download test-\t\t" "test-assumes"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap enable \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap export-key \t" "snap export-key default"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap get \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,10 @@
+source lib.exp0
+
+# info completes directories and snap files, and locally installed snaps
+chat "snap inf\t\t\t" "bar.snap*core*testdir/"
+
+# with 3+ chars, also remote snaps
+chat "test-\t\t" "test-assumes"
+
+cancel
+brexit
@@ -1,11 +1,21 @@
-source lib.exp
+source lib.exp0
# install completes directories and snaps
-chat "snap ins\t\t\t" "basic_1.0_all.snap*testdir/"
-next
+chat "snap ins\t\t\t" "bar.snap*testdir/"
# install with 3+ chars also completes store stuff
-chat "tes\t\t\t" "test-snapd-tools*testdir/"
+chat "tes\t\t\t" "test-assumes" true
+# TODO: don't list things already installed:
+chat "" "test-snapd-tools" true
+chat "" "testdir/"
+cancel
+
+# no extra space added after a directory
+chat "snap ins\t./tes\t" " ./testdir/$"
+cancel
+
+# extra space added after a file
+chat "snap ins\t./bar\t" " ./bar.snap $"
cancel
brexit
@@ -0,0 +1,15 @@
+source lib.exp0
+
+# create a key doesn't complete
+chat "snap create-key \t\t" "snap create-key ??$"
+chat "\r" "Passphrase:"
+chat "\r" "Confirm passphrase:"
+send "\r"
+
+# this can take a while
+set timeout 60
+
+next
+cancel
+brexit
+
@@ -2,7 +2,7 @@ set send_slow {1 0.1}
set timeout 5
proc delay {} {
- sleep 0.1
+ sleep 0.5
}
proc chat {outstr instr {keep false}} {
@@ -41,20 +41,20 @@ proc next {} {
delay
expect {
timeout {puts "timeout"; exit 1}
- "bash-*\[$#] "
+ "bash-*\[$#] $"
}
}
proc cancel {} {
- send ""
+ send " \r"
next
}
proc brexit {} {
send "exit\r"
expect {
timeout {puts "timeout"; exit 1}
- eof exit 0
+ eof {exit 0}
}
}
@@ -0,0 +1,7 @@
+source lib.exp0
+
+# list completes locally installed snaps
+chat "snap list \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap refresh \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap remove \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap revert \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap set \t\t" "core*test-snapd-tools"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap sign-build -k\t" "kdefault"
+
+cancel
+brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap sign -k\t" "kdefault"
+
+cancel
+brexit
@@ -1,17 +1,20 @@
summary: Check different completions
+systems: [-ubuntu-core-16-64, -ubuntu-core-16-arm-64, -ubuntu-core-16-arm-32]
prepare: |
- touch basic_1.0_all.snap
mkdir -p testdir
+ touch testdir/foo.snap
+ touch bar.snap
+ snap install core
+ snap install test-snapd-tools
+ expect -d -f key.exp0
restore: |
- rm basic_1.0_all.snap
+ rm testdir/foo.snap bar.snap
rmdir testdir
execute: |
- echo "Toplevel completion"
- expect -d -f toplevel.exp
-
- echo "Install completion"
- expect -d -f install.exp
-
+ for i in *.exp; do
+ echo $i
+ expect -d -f $i
+ done
@@ -1,4 +1,4 @@
-source lib.exp
+source lib.exp0
# --help completes
chat "snap --h\t" "snap --help $" true
@@ -13,9 +13,11 @@ chat "\t\t" "snap --version $"
cancel
# commands complete
-rechat "snap in\t\t" "info *install *interfaces"
-next
-chat "s\t" "snap install "
+rechat "snap in\t\t" "\[\n ]info\[\r ]" true
+rechat "" "\[\n ]install\[\r ]" true
+rechat "" "\[\n ]interfaces\[\r ]"
+
+chat "s\t" "snap install $"
cancel
brexit
@@ -0,0 +1,6 @@
+source lib.exp0
+
+chat "snap try \t" "testdir/"
+
+cancel
+brexit
@@ -0,0 +1,7 @@
+source lib.exp0
+
+# watch completes with change ids
+rechat "snap watch \t\t" "1 *2"
+
+cancel
+brexit

0 comments on commit 4882f21

Please sign in to comment.