14 Commits

Author SHA1 Message Date
Zygmunt Krynicki
dd2c9ebc95 tests/completion: document the "three" completion tests
There are "three" completion tests that multiply with the large number of
variatns present in the suite. The "simple" test is unsual and I don't fully
understand how it works because it does not install the test-snapd-complexion
snap at all. Instead it relies on running the completion script directly,
without the snap complete/etelpmoc script pair working across the sandbox.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-30 14:14:02 +02:00
Valentin David
a1cb7ae352 many: Install bash completion files in writable directory
Snapd installs bash completion files from snaps in
`/usr/share/bash-completion/completions` which in some distributions
is a read-only filesystem.

Instead of installing them in `/usr` we can install them within
`/var/lib/snapd` which should always be writable.

Because `/var/lib/snapd/desktop` is already in `XDG_DATA_DIRS`, we can
save the files there.

Because bash-completion 2.1 and prior do not support `XDG_DATA_DIRS`,
on older distributions, the legacy path
`/usr/share/bash-completion/completions` will still be used.
2022-06-03 10:38:37 +02:00
burak
46cd020702 tests: ensure snapd can be downloaded as a module (#11052)
LP#1948838: moved files that cause an issue during git module download to tar files in the corresponding folders

Add spread test for validating snaps can be packed and installed (as well as `snap try`'d) with various circular symlinks.
2021-12-03 14:46:53 -06:00
Pawel Stolowski
219e680df9 Use snap remove with --purge flag in most of the spread tests, to avoid unnecessary snapshots on snap removal. Some tests (those that test remove operation, snapshots, and selinux) are left intact, so remove is tested also without --purge flag where it makes sense. 2020-01-13 11:58:21 +01:00
John R. Lenton
f15432a737 data/completion: pass documented arguments to completion functions
completion functions (and commands, which we treat the same way) are
documented as receiving three arguments. I hadn't noticed, as almost
nobody uses them because most everything you need is in the different
COMP_ variables, but python's argcomplete module uses it.

This fixes that, and adds a spread test just in case.
2018-11-12 15:55:19 +00:00
Maciej Borzecki
22563764e2 tests: shellchecks, part 1
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2018-04-27 08:48:26 +02:00
John Lenton
ba27d6ada4 overlord/snapstate: support completion for command aliases (#4154)
This makes the code that manages command aliases aware of completion
support needs. That is: on alias CRUD, also CRUD the appropriate
symlinks for the completion snippets of the aliases.

For example, if you have a snap foo that has an app bar, and
foo.bar has a completer keyword in the yaml, then typing
foo.bar <tab> in bash will offer you completion via that snippet. If
you then snap alias foo.bar bar you'd expect to see the same
completion suggestions. This PR hooks things up so that you would, in
fact, get them.

This is invisible to the snap author -- the command completer
gets the original, unaliased completion request.
2017-11-14 17:14:32 +00:00
Michael Vogt
99b6109168 rename complexion to test-snapd-complexion 2017-08-29 12:21:26 +02:00
John Lenton
eac3d5deac wrappers: symlink completion snippets when symlinking binaries (#3724)
This also modifies complete.sh to support this, as well as some minor
changes to dirs and snap to accommodate.

Symlinking the snippets is itself simple enough that I didn't think it
was worth creating an ad-hoc helper, so it's just a few lines glommed
onto the end of the existing wrapper funcs (and tests).

    To be clear, I did write the helper, but between it being very few
    lines of code, it needing to return enough information to the
    caller to clean up behind it if something else went wrong, and
    especially as the other user of that helper would be the aliases
    and they don't have access to the AppInfo (which would be the
    obvious thing to pass to such helpers), I decided against it.

How aliases are going to play into completion is still an open
question on the implementation side, which I need to look into soon,
but this is not that work.
2017-08-16 10:49:50 +01:00
John R. Lenton
51b0902086 tests: bump completion expect timeout to 30s 2017-05-22 15:34:54 +01:00
Simon Fels
6c9e87b17c tests/main/completion: source from /usr/share/bash-completion
/etc/bash_completion does not exist on all distributions but
/usr/share/bash-completion does we so we can use this instead
in the test case to let it pass everywhere.
2017-05-17 09:43:07 +02:00
John R. Lenton
0cb41018ab tests: bump the timeout for tests/main/completion/lib.exp0, via DRYing it (in the laziest way) with tests/completion/lib.exp0 2017-05-10 08:53:14 +01:00
John R. Lenton
35d048ab4d fix for tests: debian does not have /snap/bin in secure_path so sudo
needs PATH=$PATH to work properly. Also, use 'slow send'
everywhere. Finally, add a comment about not filtering the 'bounced'
completion.
2017-04-28 18:38:54 +01:00
John R. Lenton
cd2573a3fd in-snap tab completion. 2017-04-25 13:00:51 +01:00