This is needed for find_namespace_packages. Make sure CI upgrades it
as well; the default shippable container doesn't meet the requirement.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Move the contents of command.py to the west.commands package
__init__.py. This makes it possible to use autoclass on the
CommandError subclasses with :show-inheritance: in documentation.
Update some other docstrings to make documentation look nicer.
No functional change expected.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Invoking 'west update' without the '-r' (rebase) option typically causes
messages like this to be issued:
WARNING: left behind ci-tools branch "mybranch"; to fast forward back,
use: git -C ../tools/ci-tools checkout mybranch
This is actually two messages somewhat confusingly compressed into one:
1. How to switch back to "mybranch",
2. "mybranch" is head of manifest-rev and doesn't need to be rebased.
Some issues:
- While 2. is secondary, it fills most of the space and draws most of the
attention.
- Whenever plain git uses "fast forward" there doesn't seem to ever be
any branch switching involved. Yet switching branch is the main
message here.
- The unfortunate "forward back" sequence sounds weird when parsed too
quickly.
As discussed and agreed with Marti on Slack, isolate and "downgrade"
the fast forward part of the message like this:
to switch back to it (fast-forward), use: git checkout...
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
A tox dependency (pluggy) is depending on pathlib2 for python 3.4
only. The version of pip available in the VM (7.x series) is too old
to support "install this only on this version of Python", causing a
failure due to a missing dependency.
"Fix" that by upgrading pip.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
- The default west list format string is not particularly readable
most of the time. Tweak it so it's better.
- replace multi-word strings like "(not set)" with single word
equivalents like "N/A", which are easier to deal with in pipelines
to cut, awk, etc.
- add a new {sha} format specifier that always produces a 40-character
SHA, or the string N/A padded to the correct length.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This lets us call print() when we can't parse the value properly
instead of dumping stack without violating the principle that all
output from west is done by the west.log module.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We currently have no way to delete options once set. This is not good
for users that want to delete things so they go back to their default
values. Add a library API and tests for this; we'll extend the config
command with options that use them next.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Delete the shim that tried to use ConfigParser, which was introduced
as a shim during development while we didn't have a release out that
had a dependency on configobj. We do now, and it's no longer needed.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Add three new environment variables which can be used to override the
configuration file locations: WEST_CONFIG_SYSTEM, WEST_CONFIG_GLOBAL,
and WEST_CONFIG_LOCAL.
Use them in the tests. This also has the beneficial side effect of
making sure that "real" system settings do not interfere with the test
environment.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We'll use this the next patch. It's useful for isolation, because the
environment is one of the things that does live on between tests.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This prints all existing config options and their values.
It can be combined with the --system, --global, and --local options
to just list the contents of those files.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Factor out read/write helpers. This is useless now but will keep the
code clean later, when we add more things this command can do.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This makes sense, and matches git config's behavior too. Stay silent
by default, but log.dbg() what happened.
Add a test case, too.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Align the description with the west.configuration docstring.
Separate the options which set the configuration file to use into
their own named argument group in the help output. List them in the
same system, global, local order that they appear in the description.
This requires using add_argument_group() instead of
add_mutually_exclusive_group(), as the latter can't take a group
name. Preserve mutual exclusion with a custom action with equivalent
semantics. This changes part of the usage from:
[--system | --global | --local ]
to:
[--system] [--global] [--local]
That's a bit unfortunate, but we're about to add other options that
don't belong in this group, and I think it's worth it to have these
three show up on their own.
While we're here, don't make the help output depend on the
platform. Let's keep it uniform.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Add basic tests for the behavior of the west.configuration APIs for
ConfigFile.SYSTEM, which were missing since we couldn't patch out the
location to somewhere safe.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Add a helper to create the configuration file if it doesn't already
exist, and call it from update_config().
Add test cases for the API-level changes, which we can do now that we
can patch out all the config file locations.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
The XDG_CONFIG_HOME variable, if set, does not specify an additional
place to look for config options: it says they should go exactly
there. Fix that. Add support for BSD platforms while we are here.
To improve testability in future patches, move the code which gets the
location for a config file into a function that we can monkeypatch
later. This will make it easier to test system level config settings.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Clean up the docstrings a bit, tweaking text and using :param xyz: to
document each parameter. Promote the "big idea" docstring to module
level.
Prefer to use `configfile` in `read_config()` to match the kwarg used
in `update_config()`, continuing to support the old way of doing
things.
Factor out a _gather_configs() helper to keep read_config() obvious.
We'll change its contents up a bit in a subsequent patch that will
make this module easier to test.
No functional changes expected.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Improve the test coverage and make sure that the command line
interface and module API work together as documented.
Improve readability by adding helpers, decreasing verbosity, and
marking the mandatory setup fixture autouse=True to cut boilerplate.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Instead of bothering to create a proper west init-based installation
when testing the configuration commands, use a fixture that just
creates what is needed, and also validates module-wide assumptions
instead of repeating them in each test case.
This improves the quality of the test by only testing what is needed,
helping to isolate these tests from unrelated errors in the manifest
handling code.
It also drops the test time from ~3.5 seconds to about ~2.5 seconds in
my Linux environment.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We don't have west in repos_tmpdir. This is yet another old docstring
that I forgot to update when we removed the bootstrapper.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Just warn instead. This is cleaner, but will also make it easier to
test commands that don't need the manifest, like 'west config', so it
helps with separation of concerns as well.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
format() throws IndexError on some invalid format strings. Handle that
rather than dumping stack.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This file is giving false negatives on Windows. To fix:
- test_manifest_freeze: expect (and escape) Windows paths
- test_forall: echo may be available in cmd.exe, but single-quoted
strings sure aren't
- test_extension_command_*: handle newlines portably
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This fixes test_project.py::test_list on Windows, as otherwise quoting
and splitting the relevant paths using shlex with POSIX rules behaves
incorrectly.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
'west config' testing is giving false negatives on Windows. To fix:
- canonicalize and fix up global config path testing
- avoid passing paths to cmd(); they don't play well with
shlex.split() and aren't necessary to make sure the config
command is behaving properly
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We need a common definition for canonicalizing paths; the lack of one
is causing issues on Windows.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
It is always possible to satisfy this constraint now that project URLs
may be specified explicitly.
(This restriction will be necessary to make manifest imports work
sensibly -- we should have done this before...).
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We don't apply the west default revision correctly if defaults is
None. Since we find it convenient to let west figure out the defaults
for us, demote it to a kwarg as well and let it be None more gracefully.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Allow each project element to explicitly specify its URL. This avoids
forcing users to name projects according to their URLs, which can be
inconvenient (and prevents us from enforcing a rule that project names
are unique).
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
We're going to add explicit project URLs to the manifest, so the
remote should no longer be a positional.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Add a helper for saving the current traceback to a temporary file and
use it appropriately from the exception handlers in main(), This avoid
throwing away information in case the error was nondeterministic.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
I'm not sure this ever worked; the args field is an empty tuple even
in Python 3.4. Use cmd and returncode attributes appropriately
instead.
Don't offer the 'for a stack trace' message here anymore: this doesn't
indicate a west error, which is what that is meant to capture.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
It takes 20 seconds on my machine to run the full set of tests, which
is slow enough that testing breaks me out of flow state.
On the suspicion that creating git repositories and using the file://
protocol when cloning (which prevents use of hardlinks) is slowing
things down, use some pytest features to avoid creating git
repositories repeatedly. Also let git use hardlinks when they are
available when cloning repositories.
On my system, this brings the average of 10 runs from 20.129 seconds
spent testing to 17.649, a 12% improvement overall. Still not ideal,
but not worth throwing away, either.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Don't copy the west tree; tox already installs it for us into the new
virtualenv, and we don't run any code out of a checked out repository
anymore, so doing things related to that is unnecessary.
This also makes the tests run a little bit faster (around a 5% or more
speedup on my system).
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
It's not clear what this is doing here. It doesn't begin with "test",
so it's not being tested, and it seems to be a copy of test_config.py
with some important features needed to avoid modifying the user's
configuration.
Delete it.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
There's no good reason to have these tests in subdirectories. Flatten
them out. Keep the directory of invalid manifests separate to keep the
directory listing clean, though.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
Get rid of the separate bootstrapper. Implement 'west init' as a
regular WestCommand which combines the bootstrapper + PostInit.
Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>