Commit Graph

208 Commits

Author SHA1 Message Date
Marti Bolivar e5457a91f0 test_project.py: delete unused import
Discovered while inspecting this file for needed changes in subsequent
patches.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-15 10:33:05 +02:00
Ulf Magnusson b7670c75ff Store the West source code and the manifest in west/
I was confused by the other design, because I intuitively expected West
metadata to go in .west/. To me the other design feels a little bit like
having an empty /home/foo/user/ directory that marks the /home/foo/
directory as containing the user's files.

Use west/ instead of .west/ to avoid "hiding" the implementation of the
building/flashing commands. I would've preferred to split them from the
repo-like functionality instead, but if they're going to be in the same
repository, then it's a decent comprise.

Remove the code that hides the west directory on Windows (via 'attrib')
as well, since it doesn't make much sense anymore.

This commit also fixes a small bug in west_topdir(): A west/ in the root
directory wasn't found.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-09-12 09:16:01 -07:00
Ulf Magnusson 063761bd67 Make 'west branch' by itself list all local branches
Analogous to running 'git branch', except for all projects. Also lists
the project(s) each branch appears in.

Example output:

  $ python3 -m west branch
  FIX-FOO            zephyr, Kconfiglib
  manifest-rev       zephyr, net-tools, Kconfiglib
  master             zephyr, net-tools
  zephyr             Kconfiglib

I'm planning to change 'git clone' into 'git init' + 'git remote add' +
'git fetch' later, which avoids creating the last two local branches.
Maybe manifest-rev should be hidden as well.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 16:43:20 -05:00
Ulf Magnusson 360897915d Add 'forall' command
Passes its command as-is to the shell, within the repositories of each
of the specified projects (or all cloned projects by default).

I was thinking of making the shell quoting for long commands optional,
by joining all the words with a space or the like, but it might get
tricky with argparse. Could look into it more later.

Piggyback some cleanup: Make the absolute path of a project available in
project.abspath, to avoid having to do a bunch of join()s with
util.west_topdir().

Fix some copy-paste comment mess-ups in the tests too.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-29 16:30:48 -05:00
Ulf Magnusson 4587ee1763 Add project commands for dealing with multiple repositories
Add simple Google repo-like functionality, for dealing with multiple Git
repositories.

The command set is mirrored after Git. All commands except
'list-projects' accept an optional list of projects, and default to all
(cloned) projects.

  - west list-projects

    Lists projects and their repositories

  - west fetch

    Clone/fetch projects. Supports 'clone-depth', for making shallow
    clones.

  - west rebase

    Rebase local branches to the revision specified in the manifest

  - west pull

    'west fetch' + 'west rebase' (similar to 'sync' in Google repo)

  - west branch

    Create a new branch in one or more repositories (for working on some
    issue)

  - west checkout

    Check out a branch in each repository that has it. Supports a -b
    flag for creating the branch first.

  - west diff

    Run 'git diff' in each repository

  - west status

    Run 'git status' in reach repository

There's no way to submit a multi-repository change for review yet.

Currently, a convenience branch 'manifest-rev' is created in each
project, which points to the revision specified for the project in the
manifest. 'manifest-rev' is updated by 'west fetch' and 'west pull'.

Local branches created with 'west branch' are set to track
'manifest-rev'. This makes e.g. a plain 'git status' or 'git pull' work
sensibly even when the manifest revision is an SHA.

We'll see if 'manifest-rev' is too magic later. It's explained in the
help texts of all the relevant commands at least.

It might be nicer to create 'manifest-rev' in e.g. refs/remotes instead
of refs/heads. Git doesn't seem to like trying to create a branch that
tracks a branch in refs/remotes unless it's a "proper" upstream branch
though.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-24 14:16:18 -05:00
Marti Bolivar 04accde952 tests: add nrfjprog runner tests
Add an exhaustive test suite.

Check expected results for all combinations of runner constructor
parameters, both when instantiating the runner directly via its
constructor and when using command line arguments via its create()
method. Ensure consistent results.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-08-20 09:17:57 -07:00
Marti Bolivar f86da451f9 tests: add pyocd tests
Add test coverage for flash, debug, and debugserver commands, using
runners created directly with their constructors, as well as via
command line arguments, with methods that would run syscalls mocked
out.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-08-20 09:17:57 -07:00
Marti Bolivar 9b7d58343f Add py.test-based test infrastructure
Follow along with what the cool kids are doing and add py.test
integration.

This patch doesn't add any test cases, but sets up packages to
test the runner classes as additional work.

To run the test suite, use:

$ python3 setup.py test

Since there are no tests, these pass.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-08-20 09:17:57 -07:00