Skip to content

Commit b890e6a

Browse files
committed
use batched testsuite
1 parent 7531fb4 commit b890e6a

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

noxfile.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def expand_envlist(value):
2121

2222
def find_dependencies(deps, env):
2323
env_factors = set(env.split("-"))
24-
for (matcher, dependency) in deps.items():
24+
for (matcher, dependency) in deps:
2525
for (included, excluded) in _split_factor_expr(matcher):
2626
if included <= env_factors and not env_factors & excluded:
2727
yield dependency
@@ -30,15 +30,15 @@ def parse_tox():
3030
config = configparser.ConfigParser()
3131
config.read("tox.ini")
3232

33-
dependencies = {}
33+
dependencies = []
3434

3535
for line in config['testenv']['deps'].splitlines():
3636
line = line.strip()
3737
if not line or line.startswith(("-r", "#")):
3838
continue
3939

4040
env_matcher, dependency = line.split(":", 1)
41-
dependencies[env_matcher.strip()] = dependency
41+
dependencies.append((env_matcher.strip(), dependency))
4242

4343
batch_jobs = {}
4444
single_jobs = []
@@ -75,15 +75,27 @@ def generate_test_sessions():
7575
dependencies, batch_jobs, single_jobs = parse_tox()
7676

7777
def add_nox_job(job_name, integrations, python_version, deps):
78-
job_name = job_name.replace(".", "").replace("-", "_")
78+
def func(session, fast=False):
79+
if not fast:
80+
session.install("-U", "pip")
81+
session.install("-e", ".")
82+
session.install("-r", "test-requirements.txt")
83+
84+
if deps:
85+
session.install(
86+
*deps,
87+
# Necessary to be able to specify double-requirements
88+
"--use-feature=2020-resolver",
89+
)
7990

80-
def func(session):
81-
session.install("-e", ".")
82-
session.install("-r", "test-requirements.txt", *deps)
8391
session.env['COVERAGE_FILE'] = ".coverage-{job_name}".format(job_name=job_name)
8492
session.run(
8593
"pytest",
86-
*["tests/integrations/{integration}".format(integration=integration) for integration in integrations],
94+
*[
95+
"tests/integrations/{integration}".format(integration=integration)
96+
if integration else "tests/"
97+
for integration in integrations
98+
],
8799
*session.posargs
88100
)
89101

@@ -128,9 +140,12 @@ def linters(session):
128140
if travis_python:
129141
@nox.session(python=travis_python)
130142
def travis_test(session):
143+
installed_base_deps = False
131144
for name, f in globals().items():
132-
if name.startswith("test-{travis_python}".format(travis_python=travis_python)):
133-
f(session)
145+
python = "pypy" if travis_python == "pypy" else "py{}".format(travis_python)
146+
if name.startswith("batchtest-{python}".format(python=python)):
147+
f(session, fast=installed_base_deps)
148+
installed_base_deps = True
134149

135150

136151
generate_test_sessions()

0 commit comments

Comments
 (0)