tests: don't test pre-unification features
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>
This commit is contained in:
parent
34de0ad936
commit
adf7e5bd2c
|
@ -1,5 +1,4 @@
|
||||||
import os
|
import os
|
||||||
from os.path import dirname
|
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -10,9 +9,6 @@ from west import configuration as config
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
GIT = shutil.which('git')
|
GIT = shutil.which('git')
|
||||||
# Assumes this file is west/tests/conftest.py, returns path to
|
|
||||||
# toplevel 'west'
|
|
||||||
THIS_WEST = os.path.abspath(dirname((dirname(__file__))))
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test fixtures
|
# Test fixtures
|
||||||
|
@ -32,8 +28,6 @@ def repos_tmpdir(tmpdir):
|
||||||
with the following contents:
|
with the following contents:
|
||||||
|
|
||||||
repos/
|
repos/
|
||||||
├── west (branch: master)
|
|
||||||
│ └── (contains this west's worktree contents)
|
|
||||||
├── manifest (branch: master)
|
├── manifest (branch: master)
|
||||||
│ └── west.yml
|
│ └── west.yml
|
||||||
├── Kconfiglib (branch: zephyr)
|
├── Kconfiglib (branch: zephyr)
|
||||||
|
@ -51,8 +45,6 @@ def repos_tmpdir(tmpdir):
|
||||||
|
|
||||||
The contents of west.yml are:
|
The contents of west.yml are:
|
||||||
|
|
||||||
west:
|
|
||||||
url: file://<tmpdir>/west
|
|
||||||
manifest:
|
manifest:
|
||||||
defaults:
|
defaults:
|
||||||
remote: test-local
|
remote: test-local
|
||||||
|
@ -72,11 +64,6 @@ def repos_tmpdir(tmpdir):
|
||||||
rr = tmpdir.mkdir('repos') # "remote" repositories
|
rr = tmpdir.mkdir('repos') # "remote" repositories
|
||||||
rp = {} # individual repository paths under rr
|
rp = {} # individual repository paths under rr
|
||||||
|
|
||||||
# Mirror this west tree into a "remote" west repository under rr.
|
|
||||||
wdst = rr.join('west')
|
|
||||||
mirror_west_repo(wdst)
|
|
||||||
rp['west'] = str(wdst)
|
|
||||||
|
|
||||||
# Create the other repositories.
|
# Create the other repositories.
|
||||||
for repo in 'net-tools', 'Kconfiglib', 'zephyr':
|
for repo in 'net-tools', 'Kconfiglib', 'zephyr':
|
||||||
path = str(rr.join(repo))
|
path = str(rr.join(repo))
|
||||||
|
@ -86,8 +73,6 @@ def repos_tmpdir(tmpdir):
|
||||||
# Initialize the manifest repository.
|
# Initialize the manifest repository.
|
||||||
add_commit(rp['zephyr'], 'test manifest',
|
add_commit(rp['zephyr'], 'test manifest',
|
||||||
files={'west.yml': textwrap.dedent('''\
|
files={'west.yml': textwrap.dedent('''\
|
||||||
west:
|
|
||||||
url: file://{west}
|
|
||||||
manifest:
|
manifest:
|
||||||
defaults:
|
defaults:
|
||||||
remote: test-local
|
remote: test-local
|
||||||
|
@ -104,7 +89,7 @@ def repos_tmpdir(tmpdir):
|
||||||
west-commands: scripts/west-commands.yml
|
west-commands: scripts/west-commands.yml
|
||||||
self:
|
self:
|
||||||
path: zephyr
|
path: zephyr
|
||||||
'''.format(west=rp['west'], rr=str(rr)))})
|
'''.format(rr=str(rr)))})
|
||||||
|
|
||||||
# Initialize the Kconfiglib repository.
|
# Initialize the Kconfiglib repository.
|
||||||
subprocess.check_call([GIT, 'checkout', '-b', 'zephyr'],
|
subprocess.check_call([GIT, 'checkout', '-b', 'zephyr'],
|
||||||
|
@ -160,8 +145,7 @@ def west_init_tmpdir(repos_tmpdir):
|
||||||
|
|
||||||
Uses the remote repositories from the repos_tmpdir fixture to
|
Uses the remote repositories from the repos_tmpdir fixture to
|
||||||
create a west installation using the system bootstrapper's init
|
create a west installation using the system bootstrapper's init
|
||||||
command -- and thus the test environment must install the
|
command.
|
||||||
bootstrapper from the current west source code tree under test.
|
|
||||||
|
|
||||||
The contents of the west installation aren't checked at all.
|
The contents of the west installation aren't checked at all.
|
||||||
This is left up to the test cases.
|
This is left up to the test cases.
|
||||||
|
@ -194,52 +178,6 @@ def check_output(*args, **kwargs):
|
||||||
raise
|
raise
|
||||||
return out_bytes.decode(sys.getdefaultencoding())
|
return out_bytes.decode(sys.getdefaultencoding())
|
||||||
|
|
||||||
|
|
||||||
def mirror_west_repo(dst):
|
|
||||||
# Create a west repository in dst which mirrors the exact state of
|
|
||||||
# the current tree, except ignored files.
|
|
||||||
#
|
|
||||||
# This is done in a simple way:
|
|
||||||
#
|
|
||||||
# 1. recursively copy THIS_WEST there (except .git and ignored files)
|
|
||||||
# 2. init a new git repository there
|
|
||||||
# 3. add the entire tree, and commit
|
|
||||||
#
|
|
||||||
# (We can't just clone THIS_WEST because we want to allow
|
|
||||||
# developers to test their working trees without having to make a
|
|
||||||
# commit -- remember, 'west init' clones the remote.)
|
|
||||||
wut = str(dst) # "west under test"
|
|
||||||
|
|
||||||
# Copy the west working tree, except ignored files.
|
|
||||||
def ignore(directory, files):
|
|
||||||
# Get newline separated list of ignored files, as a string.
|
|
||||||
try:
|
|
||||||
ignored = check_output([GIT, 'check-ignore'] + files,
|
|
||||||
cwd=directory)
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
# From the manpage: return values 0 and 1 respectively
|
|
||||||
# mean that some and no argument files were ignored. These
|
|
||||||
# are both OK. Treat other return values as errors.
|
|
||||||
if e.returncode not in (0, 1):
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
ignored = e.output.decode(sys.getdefaultencoding())
|
|
||||||
|
|
||||||
# Convert ignored to a set of file names as strings.
|
|
||||||
ignored = set(ignored.splitlines())
|
|
||||||
|
|
||||||
# Also ignore the .git directory itself.
|
|
||||||
if '.git' in files:
|
|
||||||
ignored.add('.git')
|
|
||||||
|
|
||||||
return ignored
|
|
||||||
shutil.copytree(THIS_WEST, wut, ignore=ignore)
|
|
||||||
|
|
||||||
# Create a fresh .git and commit existing directory tree.
|
|
||||||
create_repo(wut)
|
|
||||||
subprocess.check_call([GIT, 'add', '-A'], cwd=wut)
|
|
||||||
add_commit(wut, 'west under test')
|
|
||||||
|
|
||||||
def cmd(cmd, cwd=None, stderr=None):
|
def cmd(cmd, cwd=None, stderr=None):
|
||||||
# Run a west command in a directory (cwd defaults to os.getcwd()).
|
# Run a west command in a directory (cwd defaults to os.getcwd()).
|
||||||
#
|
#
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -19,11 +19,7 @@ platform = posix: (linux|darwin)
|
||||||
windows: win32
|
windows: win32
|
||||||
whitelist_externals =
|
whitelist_externals =
|
||||||
py.test
|
py.test
|
||||||
# Tests which import west modules directly from src need this PYTHONPATH
|
|
||||||
# available. The sdist which tox builds and installs only contains the
|
|
||||||
# bootstrapper modules.
|
|
||||||
setenv =
|
setenv =
|
||||||
PYTHONPATH={toxinidir}/src
|
|
||||||
# The config test will be using users HOME, therefore we redirect it
|
# The config test will be using users HOME, therefore we redirect it
|
||||||
# into tox temp dir during testing.
|
# into tox temp dir during testing.
|
||||||
HOME={envtmpdir}/pytest-home
|
HOME={envtmpdir}/pytest-home
|
||||||
|
|
Loading…
Reference in New Issue