1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
summary: indirect completion
details: |
Snapd contains a special system for tab-completion of snap applications, where
the bulk of the completion logic runs under confinement, and communicates with
a trusted, unconfined helper provided by snapd.
Like all the other completion tests, this test relies on a set of files
$variant.{complete,sh,vars} where foo $variant is one of the many variants of
the tests/complete suite: plain, plain_plusdirs, funky, files, hosts,
hosts_n_dirs, func, funkyfunc, funcarg. In each case the .vars file adds
environment variables needed by the test, the .sh script is executed during
test setup and the .complete script replaces the bash completer in the
test-snapd-complexion snap.
Like all the other completion tests this test is mostly implemented with
expect(1) to interact with bash, send and receive snippets of text.
This test installs the snap test-snapd-complexion and uses expect(1) to check
the intended behavior, while running as the test user. This test relies on the
complete.sh/etelpmoc.sh pair of scripts to communicate across the barrier
created by the snap execution sandbox. This test checks how the completion
system interacts with snap aliases.
prepare: |
(
cd ../../lib/snaps/test-snapd-complexion || exit 1
snap try
mv test-snapd-complexion.bash-completer test-snapd-complexion.bash-completer.orig
cp "${SPREAD_PATH}/${SPREAD_SUITE}/${SPREAD_VARIANT}.complete" test-snapd-complexion.bash-completer
snap alias test-snapd-complexion cplx
snap alias test-snapd-complexion.two cplx2
)
restore: |
(
cd ../../lib/snaps/test-snapd-complexion || exit 1
mv test-snapd-complexion.bash-completer.orig test-snapd-complexion.bash-completer
snap remove --purge test-snapd-complexion
)
execute: |
d="$PWD"
#shellcheck disable=SC1090
source "${SPREAD_PATH}/${SPREAD_SUITE}/${SPREAD_VARIANT}.vars"
export _OUT0 _OUT1 _OUT2 _KEY1 _KEY2
export XDG_DATA_DIRS="${XDG_DATA_DIRS:-}${XDG_DATA_DIRS:+:}/var/lib/snapd/desktop"
for c in test-snapd-complexion test-snapd-complexion.two cplx cplx2; do
sudo -u test \
CMD="${c}" \
PATH="${PATH}" \
_COMPLETE_SH=true \
XDG_DATA_DIRS="${XDG_DATA_DIRS}" \
SPREAD_PATH="${SPREAD_PATH}" \
SPREAD_SUITE="${SPREAD_SUITE}" \
SPREAD_VARIANT="${SPREAD_VARIANT}" \
_OUT0="${_OUT0}" _OUT1="${_OUT1}" _OUT2="${_OUT2}" \
_KEY1="${_KEY1}" _KEY2="${_KEY2}" \
expect -d -f "${d}/task.exp"
sudo -u test \
CMD="${c}" \
PATH="${PATH}" \
_COMPLETE_SH=false \
XDG_DATA_DIRS="${XDG_DATA_DIRS}" \
SPREAD_PATH="${SPREAD_PATH}" \
SPREAD_SUITE="${SPREAD_SUITE}" \
SPREAD_VARIANT="${SPREAD_VARIANT}" \
_OUT0="${_OUT0}" _OUT1="${_OUT1}" _OUT2="${_OUT2}" \
_KEY1="${_KEY1}" _KEY2="${_KEY2}" \
expect -d -f "${d}/task.exp"
done
|